Hey developers!
Today i would like you to help me solve my problem, which is considered to be my fault i guess
I have local script in StarterPlayerScripts, which i want to take control of my Clown NPC’s, here’s what i have written there so far
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Players = game:GetService(“Players”)
local Interactables = workspace.Interactables
local Player = Players.LocalPlayer
local Leaderstats = Player:WaitForChild(“leaderstats”)
local TweeningService = game:GetService(“TweenService”)
local WalkInfo = TweenInfo.new(4)
local Clowns = {
[8] = “Carnival”,
[14] = “Pink”,
[16] = “Airballoon”
}
repeat task.wait() until Player.Character ~= nil
repeat task.wait() until Player.Character.Humanoid ~= nil
function AnimateClown(StageNumber)
local Clown = Interactables.Clowns[Clowns[StageNumber]]
local ClownBody : Model = Clown:FindFirstChild(“Rig”)
local ClownHumanoid : Humanoid = ClownBody.Humanoid
local ClownHitBox = Clown:FindFirstChild(“Hitbox”)
local Points : Folder = Clown:FindFirstChild(“Points”)
local Sounds = ClownBody.Sounds
local IdleSounds = Sounds.Idle
local Animations : Folder = Clown.Rig.Animations
local Animator : Animator = ClownHumanoid.Animator
local Sounds = Clown.Rig.Sounds
local WalkingState = true
local HasTarget = false
local function PlayAnimation(AnimationName : Animation)
local Animation = Animations:FindFirstChild(AnimationName)
local AnimationTrack = Animator:LoadAnimation(Animation)
AnimationTrack:Play()
end
local function LoopWalk()
WalkingState = true
repeat task.wait(1)
print("X")
for i = 1, #Points:GetChildren() do
ClownHumanoid:MoveTo(Points[i].Position,Points[i])
ClownHumanoid.MoveToFinished:Connect(function()
task.wait()
end)
end
until HasTarget
end
LoopWalk()
end
Leaderstats.Stage.Changed:Connect(function()
if Clowns[Leaderstats.Stage.Value] ~= nil then
AnimateClown(Leaderstats.Stage.Value)
end
end)
When my clown has to start working, it is kinda being stuck in place, and moves not constantly, with interuptions or don’t want to walk at all. Help me fix this issue please, can’t find what’s the reason
Here’s little fragment of what is happening
UPDATE: He is working as needed after 8 seconds, so i think i am not doing something right with points restricting him to move in first 8 seconds, i don’t know what