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

I asked a question earlier but I got an answer and I understand it except theres one problem?

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"

2 comments

0

Explain? " consider making it local" is not a valid error that roblox would throw.

0

I need more information as to what you're trying to do, screenshots would be helpful.

1 answer

✓ Accepted answer

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)

1 comment

0

sorry for the huge spaces lol

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