local DB = false
local ClickDetector = game.workspace.CupGiver.CupPart.ClickDetector
ClickDetector.MouseClick:Connect(function()
if DB == false then
DB = true
local plr = game:GetService("Players").LocalPlayer
local cup = game.ServerStorage:WaitForChild("Drinks"):WaitForChild("Cup"):Clone()
cup.Parent = plr("Backpack")
wait(3)
DB = false
end
end)
Error: 12:45:03.260 - Workspace.CupGiver.CupPart.Script:9: attempt to call a nil value
You can use click.Backpack (correct me if i’m wrong)
local DB = false
local ClickDetector = game.workspace.CupGiver.CupPart.ClickDetector
ClickDetector.MouseClick:Connect(function(click)
if DB == false then
DB = true
local plr = game:GetService("Players").LocalPlayer
local cup = game.ServerStorage:WaitForChild("Drinks"):WaitForChild("Cup"):Clone()
cup.Parent = click.Backpack
wait(3)
DB = false
end
end)
.MouseClick has a parameter called playerWhoClicked, and the parameter is a Player instance, so instead of trying to use game.Players.LocalPlayer on the server you should instead use that parameter.