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

Respawn on group rank touch, help please?

Asked by 6 years ago

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.

0
ty SrslyItsJoe -11 — 6y

2 answers

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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)
Ad
Log in to vote
0
Answered by 6 years ago

thank you

Answer this question