I'm trying to make it so when a brick is touched a box is given to the player.
game.Players.PlayerAdded:connect(function(player) script.Parent.Touched:connect(onTouch) function onTouch(hit) if 6 > 2 then local box = game.Lighting["Box"]:Clone() box.Parent = player.Backpack end end end)
There's an error underline for line 3 saying " consider making it local"
You don't need the PlayerAdded function since you've already got a touch function in place. I think that is where the problem lies because it is unnecessary. However if you still wanted this function, the problem that lies there is that you haven't ended that function.
script.Parent.Touched:connect(onTouch) player = game.Players:GetPlayerFromCharacter(onTouch.Parent) if player then local box = game.Lighting["Box"]:Clone() box.Parent = player.Backpack end end)