Hello. I can not get animations to play when called from a local script inside the monster model. Sorry for the messy code.
local monster = script.Parent
local RS = game:GetService("ReplicatedStorage")
local debuggerEvent = RS:WaitForChild("DebuggerEvent")
local humanoid = monster:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local walkTrack = animator:LoadAnimation(monster:WaitForChild("WalkAnim"))
local isPlaying = false
debuggerEvent:FireServer("Loaded")
local lastPosition = monster.PrimaryPart.Position
while monster:GetAttribute("AIActive") == true do
debuggerEvent:FireServer("Loop Running")
local currentPosition = monster.PrimaryPart.Position
local distanceMoved = (currentPosition - lastPosition).Magnitude
local isMoving = distanceMoved > 0.1
lastPosition = currentPosition
debuggerEvent:FireServer(isMoving, isPlaying)
if isMoving then
if isPlaying == false then
walkTrack:Play()
isPlaying = true
end
else
if isPlaying == true then
walkTrack:Stop()
isPlaying = false
end
end
task.wait(0.2)
end
local RS = game:GetService("ReplicatedStorage")
local debuggerEvent = RS:WaitForChild("DebuggerEvent")
debuggerEvent.OnServerEvent:Connect(function(player, stage, stage1)
print(player)
print(stage, stage1)
end)
It does not even fire the events. Do local scripts not work when they are not under player? If yes, then how should I handle the animation playing?