Hello! I want to make an animation when equipped, for a test I made "print("Hello")" When I'm picking up the tool it says "Ram is not a valid member of Workspace" How can I fix that?
--Ram is a tool in a workspace
--Script: local function animation() game.Workspace.Ram.Equipped:Connect(function(mouse) print("A tool was equiped") end)
end animation()
I'm assuming you are using a local script? Local Scripts can only be run in certain places and the workspace is not one of them (unless it's in the player's character).
You can find out where they can run here.
Place the local script inside the tool and run Tool.Equipped
using script.Parent
to get the tool object.
script.Parent = Tool script.Parent.Equipped:Connect(function() end)
Make the script or local script stay in a place where it can only run once. That way it isn't re-running game.Workspace.Ram
again (because once you pick the tool up it isn't parented to workspace anymore, rather it is parented to the character).
This can be in Player.PlayerScripts
if it's a Local Script.
game.Workspace
or game.ServerScriptService
if it is a Server Script