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

I need a respawn brick for non staff members of a group?

Asked by 6 years ago

I am looking for a brick that will respawn everyone that's not a certain rank in the group, to stop glitchers and simple exploits.

1 answer

Log in to vote
0
Answered by 6 years ago

All you have to do is go through each player, check their rank in the group, and then respawn them if they're below a certain rank.

local groupId = 0 --Replace with the ID of your group
local players = game:GetService("Players")
local respawnLocation = Vector3.new(0, 0, 0) --Replace with the respawning part's position
local requiredRank = 255 --Replace with the rank number

function respawnPlayersNotWithinRank()
    children = players:GetChildren()
    for i=1, #children do
        player = children[i]
        rank = player:GetRankInGroup(groupId)
        if rank < requiredRank then
            print("Respawning "..children[i].Name)
            player:LoadCharacter()
            while not player.Character do
                wait()
            end
            local char = player.Character
            local root = char:WaitForChild("HumanoidRootPart")
            root.CFrame = CFrame.new(respawnLocation.X, respawnLocation.Y, respawnLocation.Z) + Vector3.new(0, 6, 0)
        end
    end
end

All you have to do is use the respawnPlayersNotWithinRank() function in the script whenever you need to respawn players.

Ad

Answer this question