You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to figure out why this is happening, and i want to fix it. -
What is the issue? Include screenshots / videos if possible!
Part of a rig that is animated moves slightly up when animated. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked for solutions, and i havent seen any that adresses the same problem i have.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Most of this code is from gnomecode’s tutorial on tower defense games
local Replicatedstorage = game:GetService("ReplicatedStorage")
local events = Replicatedstorage:WaitForChild("Events")
local animatetowerevent = events:WaitForChild("AnimateTower")
local function setanimation(object,Animname)
local humanoid = object:WaitForChild("Humanoid")
local animationsFolder = object:WaitForChild("Animations")
if humanoid and animationsFolder then
local animobject = animationsFolder:WaitForChild(Animname)
if animobject then
local Animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator",humanoid) -- if findfirstchild returns false, makes a new animator
local playingtracks = Animator:GetPlayingAnimationTracks()
for i, track in pairs(playingtracks) do
if track.Name == Animname then
return track
end
end
local animtrack = Animator:LoadAnimation(animobject)
return animtrack
end
end
end
local function playanimation(object,Animname,looped)
local animationtrack = setanimation(object,Animname)
if looped == true then
animationtrack.Looped = true
else
animationtrack.Looped = false
end
if animationtrack then
animationtrack:Play()
else
warn("animtrack doesnt exist")
end
end
workspace.MobFolder.ChildAdded:Connect(function(object)
playanimation(object,"Walk",true)
end)
workspace.TowerFolder.ChildAdded:Connect(function(object)
playanimation(object,"Idle",true)
end)
animatetowerevent.OnClientEvent:Connect(function(Tower,AnimName)
playanimation(Tower,"Shoot",false)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.