RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create a script for an R15 NPC"
-- server script local npcModel = Instance.new("Model", workspace) npcModel.Name = "NPC" local humanoidDescription = Instance.new("HumanoidDescription") humanoidDescription.BodyTypeScale = 1 humanoidDescription.HeadScale = 1 humanoidDescription.DepthScale = 1 humanoidDescription.WidthScale = 1 humanoidDescription.HeightScale = 1 local npcRig = Instance.new("R15", npcModel) npcRig.Name = "Rig" local humanoid = Instance.new("Humanoid", npcRig) humanoid.HumanoidDescription = humanoidDescription local rootPart = Instance.new("Part", npcRig) rootPart.Name = "HumanoidRootPart" rootPart.Size = Vector3.new(2, 2, 1) rootPart.Transparency = 1 rootPart.CanCollide = false rootPart.Anchored = false rootPart.Locked = true rootPart.BottomSurface = Enum.SurfaceType.Smooth rootPart.TopSurface = Enum.SurfaceType.Smooth local rootJoint = Instance.new("Motor6D", rootPart) rootJoint.Name = "RootJoint" rootJoint.Part0 = rootPart rootJoint.Part1 = npcRig.LowerTorso rootJoint.C0 = CFrame.new(0, 0, 0) rootJoint.C1 = CFrame.new(0, 1, 0) local animate = Instance.new("Folder", npcRig) animate.Name = "Animate" local idle = Instance.new("Animation", animate) idle.Name = "idle" idle.AnimationId = "rbxassetid://YourIdleAnimationIDHere" local walk = Instance.new("Animation", animate) walk.Name = "walk" walk.AnimationId = "rbxassetid://YourWalkAnimationIDHere" local run = Instance.new("Animation", animate) run.Name = "run" run.AnimationId = "rbxassetid://YourRunAnimationIDHere" local jump = Instance.new("Animation", animate) jump.Name = "jump" jump.AnimationId = "rbxassetid://YourJumpAnimationIDHere" local fall = Instance.new("Animation", animate) fall.Name = "fall" fall.AnimationId = "rbxassetid://YourFallAnimationIDHere" local animationController = Instance.new("AnimationController", npcRig) local animationScript = Instance.new("LocalScript", npcRig) animationScript.Source = [[ local AnimationController = script.Parent.AnimationController local Animate = script.Parent.Animate local function playAnimation(animationName, priority) local animation = Animate:FindFirstChild(animationName) if animation then local track = AnimationController:LoadAnimation(animation) track.Priority = priority track:Play() end end local function onRunning(speed) if speed > 0.1 then playAnimation("walk", Enum.AnimationPriority.Movement) else playAnimation("idle", Enum.AnimationPriority.Idle) end end local function onJumping() playAnimation("jump", Enum.AnimationPriority.Action) end local function onFreeFalling() playAnimation("fall", Enum.AnimationPriority.Action) end script.Parent.Humanoid.Running:Connect(onRunning) script.Parent.Humanoid.Jumping:Connect(onJumping) script.Parent.Humanoid.FreeFalling:Connect(onFreeFalling) ]]