✓ Accepted answer
In English, this is what you want to do:
When a player touches a brick, they get kicked
We should formalize this a bit more:
When something touches a brick, if that something is a player's character, then kick that player
Note: there is nothing in that that would respond to a player joining. Think about the problem before you just write something down hoping it will work. It doesn't work like that.
Touched events are events, so they require a connection, just like your use of PlayerAdded.
They are not function values. Beside that, they would need to be a function: the Kick method returns nil so at best this script would be
- kicks player upon entering
- set
onTouched to nil
When something touches a brick, if that something is a player's character, then kick that player
function onTouch(partTouching)
if partTouching.Parent then
local player =
game.Players:GetPlayerFromCharacter(partTouching.Parent);
if player then
player:Kick();
end
end
end
script.Parent.Touched:connect( onTouch );