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

Can someone help me make a basic respawning script?

Asked by 6 years ago

Hi everyone! Could someone write a script that basically states that upon someone joining a game they are automatically respawned? Thanks!

2 answers

Log in to vote
1
Answered by 6 years ago
game.Players.PlayerAdded:Connect(function(Player)
Player:LoadCharacter()
end)
0
Posted a follow up to this in my reply TerenceWalsh 2 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

@LuaDesign

Basically, I've been trying to develop a system to where we base my teaming system off of specific department or agency groups (I work for a United States group). After placing someone on a team, my script is dependent on the subject being respawned in order to be placed on the correct team. For some reason, I did not incorporate my own respawning system correctly in the script (since I'd like it to occur AFTER team placement).

Could you gander over and see what I did incorrectly?

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
    -- team colors
    local ManageColor = "Magenta"
    local CIAColor = "Daisy orange"
    local FBIColor = "Really blue"
    local DOSColor = "Mauve"
    local DODColor = "Bright red"
    local DOJColor = "Grime"
    local CONGRESSColor = "Crimson"
    local CIVColor = "Deep orange"
    local POTUSColor = "Storm blue"
    local PRIColor = "Plum"
    local MEXICANColor = "New Yeller"
    local USCColor = "Terra Cotta"
    local SSColor = "Really black"
    local USCPColor = "Cyan"
    local VPOTUSColor = "Deep blue"
    local WHSColor = "Institutional white"
    -- group ids
    local USAID = 2533418
    local WHSID = 2533427
    local USCID = 2547905
    local SSID = 2534270
    local CPID = 2660170
    local FBIID = 2679501
    local CIAID = 2534313
    local DODID = 1191022 or 2533979
    local DOSID = 2533483
    local DOJID = 2534038
    local SENATEID = 2533428 
    local HOUSEID = 2533429
    -- -- init
    -- teams
    if player:GetRoleInGroup(USAID) == "Founder" or player:GetRoleInGroup(USAID) == "Group Manager" then
        player.TeamColor = BrickColor.new(ManageColor)

    elseif player:GetRoleInGroup(USAID) == "President of the United States" then
        player.TeamColor = BrickColor.new(POTUSColor)

    elseif player:GetRoleInGroup(USAID) == "Vice President of the United States" then
        player.TeamColor = BrickColor.new(VPOTUSColor)

    elseif player:GetRoleInGroup(USAID) == "Foreign Dignitary" then
        player.TeamColor = BrickColor.new(DOSColor)

    elseif player:IsInGroup(USAID) and player:GetRoleInGroup(USAID) == "Immigrant" or player:GetRoleInGroup(USAID) == "Immigrant [Failed]" then
        player.TeamColor = BrickColor.new(MEXICANColor)

    elseif player:IsInGroup(USCID) then
        player.TeamColor = BrickColor.new(USCColor)
        if player:GetRoleInGroup(USCID) == "Pending" then
            player.TeamColor = BrickColor.new(USCColor)
        end

    elseif player:IsInGroup(SENATEID) then
        player.TeamColor = BrickColor.new(CONGRESSColor)

    elseif player:IsInGroup(HOUSEID) then
        player.TeamColor = BrickColor.new(CONGRESSColor)

    elseif player:IsInGroup(SSID) then
        player.TeamColor = BrickColor.new(SSColor)
        if player:GetRoleInGroup(SSID) == "Suspended" then
            player.TeamColor = BrickColor.new(CIVColor)
        end

    elseif player:IsInGroup(CPID) then
        player.TeamColor = BrickColor.new(USCPColor)
        if player:GetRoleInGroup(CPID) == "Suspended" then
            player.TeamColor = BrickColor.new(CIVColor)
        end

    elseif player:IsInGroup(FBIID) then
        player.TeamColor = BrickColor.new(FBIColor)
        if player:GetRoleInGroup(FBIID) == "Pending" or player:GetRoleInGroup(FBIID) == "Suspended" then
            player.TeamColor = BrickColor.new(CIVColor)
        end

    elseif player:IsInGroup(CIAID) then
        player.TeamColor = BrickColor.new(CIAColor)

    elseif player:IsInGroup(WHSID) then
        player.TeamColor = BrickColor.new(WHSColor)

    elseif player:IsInGroup(DOSID) then
        player.TeamColor = BrickColor.new(DOSColor)

    elseif player:IsInGroup(DOJID) then
        player.TeamColor = BrickColor.new(DOJColor)

    elseif player:IsInGroup(DODID) then
        player.TeamColor = BrickColor.new(DODColor)
        local ARMYID = 1191022
        local DODID = 2533979
        if player:GetRoleInGroup(ARMYID) == "[Pending]" or "[BCT]" or player:GetRoleInGroup(DODID) == "Suspended" then
        player.TeamColor = BrickColor.new(CIVColor)
        end

    elseif player:IsInGroup(USAID) then
        player.TeamColor = BrickColor.new(CIVColor)

    -- follow through
    player:LoadCharacter()
    end
end)

Answer this question