Any ideas on how to fix this error?
This error occurs probably because script cannot find any object classified as “Tool” in player’s character. Are you sure any tool exists in player?
You should avoid stacking methods when there is a possibility that the object you’re seeking does not exist.
local equippedTool = game.Players.LocalPlayer.Character:FindFirstChildOfClass('Tool')
if equipped.Value == 1 and equippedTool and equippedTool:FindFirstChild(equipped.Value) then
Tools are in players’ Backpack, not their character model, unless it’s actually in their model for odd reasons?
game.Players.LocalPlayer.Backpack:FindFirstChildOfClass("Tool")
Also please don’t use light mode. Use dark mode. It’s better for your eyes. Trust me, it is.
When a tool is equipped, it is removed from the backpack and parented to the player’s character.
I believe OP is looking to reference the currently-equipped tool.
I don’t work with Tools so, eh, didn’t know.
Do we know what script.Parent
is? It’s a button, sure, but is it only visible when the tool is equipped?