I can run this script Studio and locally it will perform fine, but when I have a friend test it or I run it outside of Studio nothing happens and nothing appears in the output
I wouldn’t use the Mouse Object to detect when the tool gets activated, there’s already an Event for Tools made for this called the Activated Event lol
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator")
local Animation = Tool:WaitForChild("Animation")
local LoadAnim = Animator:LoadAnimation(Animation)
Tool.Activated:Connect(function()
LoadAnim:Play()
end)
Tool.Unequipped:Connect(function()
LoadAnim:Stop()
end)
Also you should define your variables ahead of time, try not to make them entirely all global
I tried all of these and for some reason, none of them worked. Could it have something to do with the fact that I’m in team create? I’ve tried 100 different scripts and none of them work properly but also don’t print any errors in the output.
If it’s a LocalScript, the changes would only be made to your side & your friend won’t be able to see the animation being played (Same thing goes & vice versa)
You can change it to a ServerScript instead with referencing the variables like so, and it should play globally for everyone to see:
local Tool = script.Parent
local Animation = Tool:WaitForChild("Animation")
local Character, Animator, LoadAnim
Tool.Activated:Connect(function()
Character = Tool.Parent
Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator")
LoadAnim = Animator:LoadAnimation(Animation)
LoadAnim:Play()
end)
Tool.Unequipped:Connect(function()
LoadAnim:Stop()
end)