Im trying to make a script where if you touch a torso of a player (no humanoid in it), it gives you Rum, but it says "tried to index player, a nil value?"
Script :
local player = game.Players.LocalPlayer local money = player:WaitForChild("Money") function onMouseClick(player) if player.money >= 3 then local Rum = game.Lighting:FindFirstChild("Rum") Rum:Clone() Rum.Parent = player.Backpack end end
script.Parent.MouseClick:connect(function(player) --because it's in clickdetector ;) local money = player:findFirstChild("Money") if money.Value >= 3 then local Rum = game.Lighting:FindFirstChild("Rum") Rum:Clone() Rum.Parent = player.Backpack end end)
You need a local script in order to reference game.Players.LocalPlayer or just commonly known as local player. You will just have to put this into a local script and put that local script into a directory that gets put into the local player