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

Respawn on group rank touch, help please?

Basically, I have made a respawn on touch script. Just wondering how I'd add group ranking into it. So I can keep trolls, exploiters, etc out of the STAFF only area. e.e What I've done so far:

script.Parent.Touched:connect(function(Hit) -- Activates if Touched
Player = Game.Players:GetPlayerFromCharacter(Hit.Parent)  -- Checks if what touched has a player.
if Player then -- Checks the Player
Player:LoadCharacter() -- Loads if it is a Player
end -- Ends the "if" statement.
end) -- Ends the function.

1 comment

0

ty

2 answers

✓ Accepted answer

RBXScriptSignal:connect() is deprecated, prefer RBXScriptSignal:Connect() instead. I also recommend indenting once per scope.

local GroupId = 30
local StaffRolesetId = 5

script.Parent.Touched:Connect(function(TouchingPart)
	if not TouchingPart.Parent then
		return
	end

	local Player = game.Players:GetPlayerFromCharacter(TouchingPart.Parent)

	if not Player then
		return
	end

	if Player:GetRankInGroup(GroupId) >= StaffRolesetId then
		return
	end

	Player:LoadCharacter()
end)

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