i don't mean like the player model i mean the actual player in the players tab under workspace
if i started from script.Parent.Touched:Connect(function(hit)
i thought it might be this but this code doesn't work, it says retracee is not a valid member of players, even though I see myself in the players..?
script.Parent.Touched:Connect(function(hit) local plr = hit.Parent game.Players(plr.Name):Destroy() end)
then I tried this but I got lost and didn't know how to access the player who had the Id, also it seems like it can't see my userid from a touched event because the logs say userid is not a valid member of model
local players = game:GetService("Players") script.Parent.Touched:Connect(function(hit) local plr = hit.Parent local player1s = players:GetChildren() if player1s.CharacterAppearanceId == plr.UserId then player1s:Destroy() end end)
This is what you would have to do:
script.Parent.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) --is the part touching a player or another part? if player then --if it is a player that touched the part, then continue... player:Destroy() --you have the player pulled out right here, now what do you want to do with this information... write your function here... do you want to destroy your player? do you want to change the player's name? All of what you are trying to do goes here. end end)
This script would display the player's name in the output.