I'm making a script, and in the output, the only error is that I haven't defined the player, its for a script to equip a tool in a GUI, for a inventory system I made, but the function is : "script.Parent.MouseButton1Click:connect(function(player)", but I need to define player to define the pickaxe. So how would I define the player, here is the code :
local pickaxe = player.Backpack:FindFirstChild("Pickaxe") --------------------------- "player" definition needed here 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)
If your code is in a local script you can define player with the following code:
local player = game.Players.LocalPlayer
LocalPlayer is a property in game.Players
that returns Player only if it is called in a localscript, calling in a regular script will result in error
Tips on localscripts