Changing RespawnTime for a certain Player

Hello devs! So I am wondering, if there’s any way to change a certain Player’s RespawnTime.

2 Likes

Try using

local Players = game:GetService(“Players”)


if game.Players.LocalPlayer.Name == "Your Name" then
  Players.RespawnTime = time
else
 Players.RespawnTime = time
end
2 Likes

RykaxYT’s response is not really the solution you are looking for, since LocalPlayer cannot be accessed from Scripts, and if it were a LocalScript, the client cannot change their respawn time.

What you want to do is disable CharacterAutoLoads (now you have to manually load players’ characters) and do the following, which I will explain:

local Players = game:GetService("Players")
local NORMAL_RESPAWN_TIME = 3
local SPECIFIC_RESPAWN_TIME = 1

Players.PlayerAdded:Connect(function(player) -- Listen for PlayerAdded to get the player
      player.CharacterAdded:Connect(function(char) -- Listen for CharacterAdded to get the player's character
      local humanoid = char:WaitFoChild("Humanoid")

      humanoid.Died:Connect(function() -- Wait for player's character to die
         if player.Name == "InsertSpecificName" then -- Check for the specific player
            task.wait(SPECIFIC_RESPAWN_TIME)
         else
            task.wait(NORMAL_RESPAWN_TIME)
         end
         player:LoadCharacter() -- Manually respawn player's character
      end)
   end)
end)
8 Likes

Is there a way to do this on client?

Why would you want to do this on the client? That introduces so many security vulnerabilities, such as letting a player respawn instantly (or not respawning at all).

Respawning players via clients will just open a huge can of worms due to replication issues. I don’t recommend it.

I’m just asking if it’s possible.

Done some modifications to this script to include a table with player, and with a ModuleScript, for say if you had a VIP gamepass and the player is added by a script, but anyways, here’s the scripts.

Main respawn script

local Players = game:GetService("Players")
local SpecificPlayers = require(script.__Module --[[Name the module whatever you want, but type the path here.]])
local NormalTime = 3
local FastTime = 0.25

Players.PlayerAdded:Connect(function(player) -- Listen for PlayerAdded to get the player
	player.CharacterAdded:Connect(function(char) -- Listen for CharacterAdded to get the player's character
		local humanoid = char:WaitForChild("Humanoid")

		humanoid.Died:Connect(function() -- Wait for player's character to die
			if table.find(SpecificPlayers.tab, player.UserId) then -- Check the player's ID from the table.
				task.wait(FastTime)
			else
				task.wait(NormalTime)
			end
			player:LoadCharacter() -- Manually respawn player's character
		end)
	end)
end)

Module

local ___ = {}

___.tab = {

	-- Add whatever you need in here, but USE UserId's

}

return ___

So yeah, a multi player solution. Just ad an or table.find(SpecificPlayers.whateverTable) to the if statement, and add that table in the module. So, this should work better, instead of just one player.