Hello, I would like to achieve the proper working function for a script I have been trying to do.
The issue is I have been trying many ways to resolve a proper way to use some of the code I have done but they all ended up failing in the process. I have tried ways to achieve the result with tables, modules and events but non seem to work properly.
Basically I would like when a GUI text-box is pressed it will activate a animation to play on a specific dummy. I would really like if anybody could help me with this issue. I have been trying a lot to do it But i dont think I can properly make it correctly so if anybody has a solution or info please tell me. -P.s This is very important for my game.
This is my way to activate for the to play the animation.
local textButton = script.Parent
local npc = workspace.npc -- path to npc
local animation = npc.Animation -- path to animation property
textButton.MouseButton1Click:Connect(function()
local anim = npc.Humanoid:LoadAnimation(animation)
anim:Play()
end)
(This is clientside, which means player in server or other clients can’t see, but tell me if you want it serverside)
Thank you for this I believe this will work perfectly but also I do not have an animation property I only have a script that runs the animation inside of the dummy so maybe any help for that? Like do I need to add an animation track to it or something
So do I refer to the script? Because this is the script I have in it: local Character = script.Parent
local animation = Instance.new(‘Animation’)
local track = nil
animation.AnimationId = “rbxassetid://6867024177”
track = Character.Humanoid:LoadAnimation(animation)
track:Play()
I just need a path to the animation but Idk if i refference the script because the script is the only thing in the dummy no animation tracks or scripts besides it
Ok I removed the script in the dummy, So in local animation = npc.Animation – path to animation property What would I put? The text button is in starter gui and the dummy is in workspace
the local script u gave I put in the text button and the only thing I do not get is:
local animation = npc.Animation – path to animation property (I dont know what to put there)
Sorry for making you confused, you don’t need an animation property.
It’d look like this.
local textButton = script.Parent
local npc = workspace.npc
local animation = npc.Animation
textButton.MouseButton1Click:Connect(function()
local anim = npc.Humanoid:LoadAnimation(animation)
anim:Play()
end)
You need to run the code on the server, only the player’s animation replicate but NPC’s animation don’t replicate. Fire a Remote event to the server and then play the animation.
ah ok. sorry for the late reply i forgot about this. heres the script (it should be a script under the gui button):
script.Parent.MouseButton1Click:Connect(function()
local humanoid = game.Workspace.Dummy.Humanoid --change the path if ur dummy is named smth else
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=your animation id"
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
end)