How would I change the respawn time for a certain team?

So basically I have two teams in my game, the lobby team and the playing team and I want the lobby team to have a RespawnTime of 0.3 seconds, while I want the playing team to have a RespawnTime of 10 seconds, how would I do this?

I have already tried making a local script under StarterPlayerScripts that does a while loop and if the player’s team is the playing team it sets the respawn time to 10, else it sets it to 0.3 seconds. But for some reason this doesn’t work although I see it change the respawn time in the client. Maybe it’s because the RespawnTime can only be change on the server side. But how could I make it different for a certain team?

Have you tried using the Players.PlayerAdded event on the server?

hmmmm what do you mean exactly?

You’ll have to manually spawn the character in by disabling Players.CharacterAutoLoads (boolean) and check if a player dies via player.CharacterAdded and humanoid.Died then repsawn them using player:LoadCharacter(). While obviously adding in your cooldown before you call this method.

2 Likes

Damn I thought there was another way to do it instead of disabling auto load, that’s kind of annoying, anyway… ima go do that now

1 Like

Maybe you can use this local script in SPS:

local ChangeRespawnTimeEvent = game.ReplicatedStorage.ChangeRespawnTimeEvent

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        -- Listen for when the player's team changes
        character:WaitForChild("Team"):GetPropertyChangedSignal("Value"):Connect(function()
            -- Send the team information to the server
            ChangeRespawnTimeEvent:FireServer(player.Team.Value)
        end)
    end)
end)

and then listen to it with a server script

local ChangeRespawnTimeEvent = game.ReplicatedStorage.ChangeRespawnTimeEvent

ChangeRespawnTimeEvent.OnServerEvent:Connect(function(player, team)
    local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
    if humanoid and team then
        if team.Name == "PlayingTeam" then
            humanoid.RespawnTime = 10
        else
            humanoid.RespawnTime = 0.3
        end
    end
end)
You may need to change some things to fit into your system

that was what I thought of doing but unfortunately the RespawnTime is not a property of the humanoid but of the Players service rip

hm maybe this will help?

Local script SCS

local ChangeRespawnTimeEvent = game.ReplicatedStorage.ChangeRespawnTimeEvent

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        -- Listen for when the player's team changes
        character:WaitForChild("Team"):GetPropertyChangedSignal("Value"):Connect(function()
            -- Send the team information to the server
            ChangeRespawnTimeEvent:FireServer(player.Team.Value)
        end)
    end)
end)

Server script:

local ChangeRespawnTimeEvent = game.ReplicatedStorage.ChangeRespawnTimeEvent

ChangeRespawnTimeEvent.OnServerEvent:Connect(function(player, team)
    if team then
        if team.Name == "PlayingTeam" then
            player.RespawnTime = 10
        else
            player.RespawnTime = 0.3
        end
    end
end)

@XxprofessgamerxX’s reply deserves the “Solution” mark, in my opinion. His/her way of doing this is ideal. A similar post was made before, and the solution was basically the same: https://devforum.roblox.com/t/changing-respawntime-for-a-certain-player.

In this scenario, your Script should look like this:

local Players = game:GetService("Players")

Players.CharacterAutoLoads = false

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local humanoid = character:WaitForChild("Humanoid")
        humanoid.Died:Connect(function()
            if player.Team == "Lobby" then
                task.wait(0.3)
            elseif player.Team == "Playing" then
                task.wait(10)
            end

            player:LoadCharacter()
        end)
    end)
end)

The code is super simple.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.