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

Trying to make a brick that clears your inventory ,why isn't this working?

local Part = script.Parent
Part.Touched:connect(function(hit)
       local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
       If Player then
             Player.Backpack:ClearAllChildren()
       end
end)

1 comment

0

I haven't tested this yet - but it's important to note that when a tool is equipped, it is found inside the Character model.

1 answer

✓ Accepted answer
local Part = script.Parent
Part.Touched:connect(function(hit)
       local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
       if Player then -- 'if' starts with a lower case
             Player.Backpack:ClearAllChildren()
       end
end)

2 comments

0

Ah wow, nice, didn't spot the if.

0

If anything that is usually a color and now is not, reread what you did.

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