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

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

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

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.

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