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

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

Asked by 6 years ago

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"

0
Explain? " consider making it local" is not a valid error that roblox would throw. H4X0MSYT 536 — 6y
0
I need more information as to what you're trying to do, screenshots would be helpful. IcyEvil 260 — 6y

1 answer

Log in to vote
0
Answered by
tantec 305 Moderation Voter
6 years ago
Edited 6 years ago

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)
0
sorry for the huge spaces lol tantec 305 — 6y
Ad

Answer this question