I have this in a local script, inside a textbutton, to equip a tool, the tool is in replicated storage, plsfix
local player = game.Players.LocalPlayer local pickaxe = player.Backpack:FindFirstChild("Pickaxe") script.Parent.MouseButton1Click:connect(function(player) local pickaxe = player.Backpack:findFirstChild("Pickaxe") if script.Parent.Text == "Unequip" then pickaxe.Parent = game.ServerStorage script.Parent.Text = "Equip" else pickaxe:Clone().Parent = player.Backpack script.Parent.Text = "Unequip" end end)
You have player
written as a parameter for the function you are connecting to MouseButton1Click
, but MouseButton1Click
does not give you any parameters, so player
is being locally redefined as nil. Change :connect(function(player)
to :connect(function()