Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local replicatedstorage = game:GetService("ReplicatedStorage")
- local event = replicatedstorage:WaitForChild("Events")
- local animatetowerevent = event:WaitForChild("AnimateTower")
- local function setAnimation(object, animName)
- local humanoid = object:WaitForChild("Humanoid")
- local animationsfolder = object:WaitForChild("Animations")
- if humanoid and animationsfolder then
- local animationsobject = animationsfolder:WaitForChild(animName)
- if animationsobject then
- local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator",humanoid)
- local animationstrack = animator:LoadAnimation(animationsobject)
- return animationstrack
- end
- end
- end
- local function playAnimation(object, animName)
- local animationstrack = setAnimation(object ,animName)
- if animationstrack then
- animationstrack:Play()
- else
- warn("Animation track dose not exist")
- return
- end
- end
- workspace.Grassland.Mob.ChildAdded:Connect(function(object)
- playAnimation(object, "Walk")
- end)
- workspace.Grassland.Tower.ChildAdded:Connect(function(object)
- playAnimation(object, "Idel")
- end)
- animatetowerevent.OnClientEvent:Connect(function(tower, animName)
- playAnimation(tower, animName)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement