I am not sure what is exactly wrong with my kill script. I have tried many varitions of it though for some reason anything I do with FindFirstChild never works. I want it so that if your in the group and your rank 2 it allows you in but if not then it kills you.
script.Parent.Touched:connect(function(hit) game.Players.PlayerAdded:connect(function(Player) if Player:GetRankInGroup(2758901) == 2 then print("Good") else if hit.Parent:FindFirstChild("Humanoid") >= true then hit.Parent.Torso:Remove() end end end) end)
The console shows nothing and i am guessing that its my functions.
The playeradded event won't start running until after it's been touched, but for it to be touched by a character, a player already has to be present, right? You should use GetPlayerFromCharacter
instead.
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player then if Player:GetRankInGroup(2758901) == 2 then print("Good") else hit.Parent.Torso:Remove() -- Moved the check for humanoid up. end end end end)
Nice try, but you never define a player variable, nor check if it was a Player!
script.Parent.Touched:connect(function(hit) local p = game.Players:GetPlayerFromCharacter(hit.Parent) if p then if p:GetRankInGroup(2758901) == 2 then print("Good") else p.Character:BreakJoints() -- Better way to kill end end end)