Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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)

0
Is that code in a LocalScript? User#2146 0 — 6y
0
no bossay8 8 — 6y

1 answer

Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago

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)
Ad

Answer this question