✓ Accepted answer
Okay, so all you have to do is change the "script", to "LocalScript", then try putting in this code I've been working on inside the local script (it's a revised of your script but fixed i guess, i mean i'm not perfect, but it is working for me, instead of using your animation "since i do not know it", I used my own animation and found the test successful in studio.)
local Tool = script.Parent
local humanoid = nil
local connection = nil
local playing = false
activated = nil
local CanActivate = true
local player = game.Players.LocalPlayer
local character = player.Character
function onEquippedLocal(mouse)
humanoid = Tool.Parent:FindFirstChild("Humanoid")
activated = humanoid:LoadAnimation(Tool.ZTZ)
connection = mouse.Button1Down:connect(activatedd)
end
function onUnequippedLocal()
humanoid = nil
if activated ~= nil then
activated:Stop()
activated:remove()
activated = nil
end
connection:disconnect()
end
function activatedd()
if playing then
return
end
playing = true
if CanActivate == true then
local animation = character.Humanoid:LoadAnimation(script.Parent.ZTZ)
animation:Play()
wait(10)
animation:Stop()
playing = false
end
end
Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)
31 comments
The line where it says "script.Parent.Activated", is it a screengui?
No, there is no Gui involved with in the script or tool.
What I mean is, is it a script or localscript and also is it's parent a screengui?
Its a script, and no it's not a parent to a screengui.
I'm confused, how can it be activated when there is nothing activating it, are you using a click function like "MouseButton1Click"?
Okay, what is the classname for the script's parent? Is it a model, etc
And here is where the stupid mistake may come in. My idea was is it would detect any activations with mouse clicking, buttons, or screen tapping. This would be my first time trying this, but this question has been going on for quite some time.
Class name? It's parent is the tool itself, that I can say. Forgive me for my ignorance.
For a better understand, do you mind screenshot the workspace, Where your script is and what parent is it under?
Yeah, give me a second. And I really appreciate for what your doing here.
No problem, I usually get more details to help out. For an example, https://prnt.sc/iww2fd
Alright, i've got the screenshot. Now how can show you it?
go to
go to prnt.sc and u can insert images.
My mistake, I was testing it on a block... :/
ohhh
you mean a part?
Ok, here is the actual thing. https://prnt.sc/j9pl2s The tool is called, "Tool"
So my idea was, who ever would be using the tool would click. The the script would use ZTZ (Animation) and load it.
ok, shouldn't be a hard one
So its not the script? But the placement?
I have tried many things to get this test right, but so far I haven't been so succesful.
script should work
So what am I missing?
Allow me to give this a try for a second
if you find any errors don't be afraid to tell me, I make mistakes as well.
I don't know what to say. Your script looks much more complex than my own. Sorry if I have caused you any trouble. This is wonderful! :D Works perfectly.
Any suggestion on where I should learn how to script so I know how to do this on my own in the future?
Thank you, appreciate it. It need more functions for it to work, your scripting wasn't as bad as you think, you actually did pretty well, I used your scripting to finish off the script.
Remember, do not hesitate to let me know if there is an error, you can use output to for more info. Scripts can break, so please if it has any problems just let me know. (Not saying I'm the best, but I'd love to get to be part of your projects.)
Know where I can farther learn how to script so I may get better at scripting?