Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't my tool giver work, it doesn't give tools?

local cd = script.Parent.ClickDetector
local Player = game.Players.LocalPlayer
local tools = game.Lighting.Tools
local pack = Player:FindFirstChild("Backpack")
cd.MouseClick:connect(function()
	tools.Cup:Clone().Parent = pack
end)

NO WORKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK

15:48:46.337 - Workspace.Handle.Script:4: attempt to index local 'Player' (a nil value)

2 comments

0

Is that code in a LocalScript?

0

no

1 answer

✓ Accepted answer

Fixed it, you just had to put local player inside of the function:

local cd = script.Parent.ClickDetector
local tools = game.Lighting.Tools

cd.MouseClick:connect(function()
	local Player = game.Players.LocalPlayer
    tools.Cup:Clone().Parent = Player:WaitForChild("Backpack")
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.