Weird RespawnTime "Glitch"?

(this is in scripting support because im not sure if i have to fix it, or if its a glitch with my studio)

Basically, For one of my gamemodes, it sets the respawn time really high so players wont respawn after dying there, Then, after the round it forcefully respawns every player, and sets the respawn time back to its normal amount. But, for some reason the next round, despite the respawn time being the same, players act like the respawn time is still really high, Using the explorer when the game is running tells me that the respawn time IS back to normal, or is high, So its clearly not the code, Im really unsure what to do, If anyone can help that’d be great.

Does anyone know if im missing certain code?

TL;DR: Players still use the past respawn time even when its changed

1 Like

Could you maybe show us the script?

2 Likes

I looked through the script multiple times, I don’t think anything is wrong with it.

Like i stated, It simply changes the RespawnTime from Game.Players, It doesn’t have its own respawn system, Or anything

also, the script is really long and those parts are far apart and i’d prefer to not send the entire script.

Im simply just changing the RespawnTime in the middle of the game, I have no idea why players act so odd with it.
If it really was the script, I would’ve figured it out by now.

1 Like

No it’s just that I can help debug it easier if I see the script

2 Likes

Okay then.

I really doubt this will help whatsoever, but heres an example code of how im changing it (this is nothing like the real script, its just showing ways that im doing this stuff)

--to respawn character
plr:LoadCharacter()
--to change respawn time
game.Players.RespawnTime = --number is here

Nothing in the script is useful here, It changes the respawn time, and changes it back when it needs to.

I guess i will try the script in an empty baseplate. ill come back with the results.

1 Like

Why is there no number inputted?

2 Likes

Because, Like i said, its not the real script, its just showing the way im doing stuff, in the real script, there IS a number placed there.

1 Like

Very wired. I tested this myself and it doesn’t seem like the second input is registered

1 Like

Try turning off “CharacterAutoLoads” in players
image

1 Like

I don’t think that has anything to do with my problem, Thats just gonna make so players don’t spawn, and so you have to respawn them manually, What im trying to figure out is why the respawn time acts weird for me.

1 Like

Actually It might just solve your issue

1 Like

No, It won’t, Plus, I’d prefer to not make a completely new respawn system just because of one gamemode.

From more testing. It seems if you change the respawn time, and reload a plr, that plr will use the past respawn time, Nothing in my code does anything like this, So it might be a roblox glitch, Or a studio glitch.

Have you tried loading the players after setting the respawn time?

1 Like

It sounds like you’re storing the old value when the player spawns and then having the respawn manager use that old value when the player dies instead of check and use Players.RespawnTime when the player dies.

(Parented to StarterCharacterScripts)

local Player = game.Players:GetPlayerFromCharacter(script.Parent)
local PlrCharacter = Player.Character --// Not necessary if you don't need to do anything with the character when it dies
Player.Character.Humanoid.Died:Connect(function()
    --// Do whatever else you need to do here
    task.wait(game.Players.RespawnTime)
    Player:LoadCharacter()
end)
1 Like

Well uh, No.

Im simply just changing the RespawnTime, I’m not using any custom respawn system or anything like that, Its just the default roblox system, All im doing is changing the respawn time.

1 Like

Yes, i have, hasnt worked at all though, they still use the old respawn time

1 Like

Interesting.

Well, setting CharacterAutoLoads to false like the others were suggesting then using that bit of code I wrote may fix your problem. Setting CharacterAutoLoads to false will disconnect everything from Roblox’s default system and give you complete control over respawning. Dealing with player joins is as easy as game.Players.PlayerAdded:Connect(function(plr) plr:LoadCharacter() end)

2 Likes

This has actually helped a lot.

First off, It fixed the issue the topic is talking about.

Second off, It gives me way more freedom to make more things if i wanna disable respawns for a certain player.

Though, I have a few issues.
For instance, if i made so when you join the middle of a round, it wont load your character, but rather give you spectating UI. My issue is that none of the main GUI shows up (ones in starter gui dont get placed in)
Also, for some reason i have to respawn the player twice in order for the spectating GUI to go away (reset on spawn is enabled for the GUI)

Also also, Is there anyway for me to use something other than the .Died event? in my other scripts, the died event has been really delayed (i am aware of why it happens) And im worried that it might take a really long time for people with bad wifi to respawn.

1 Like

Oh right, I forgot about the UI nightmare that follows. Fortunately, I just finished dealing with it myself, so I can try to help how I can. What I’ve managed to piece together basically replicates normal ResetOnSpawn behavior and extends it to work with players who haven’t spawned in yet.

for i,v in pairs(game.StarterGui:GetChildren()) do
	if v.ClassName == "ScreenGui" then
		v.Parent = script
		v:SetAttribute("ResetOnSpawn",v.ResetOnSpawn)
		v.ResetOnSpawn = false
	end
end

game.Players.PlayerAdded:Connect(function(plr)
	for i,v in pairs(script:GetChildren()) do
		v:Clone().Parent = plr.PlayerGui
	end
	plr.CharacterAdded:Connect(function()
		for i,v in pairs(plr.PlayerGui:GetChildren()) do
			if v:GetAttribute("ResetOnSpawn") == true then
				local Clone = script[v.Name]:Clone()
				v:Destroy()
				Clone.Parent = plr.PlayerGui
			end
		end
	end)
end)

Your spectating GUI should be 100% client-sided, so you can just have a LocalScript in StarterPlayerScripts drop a copy of a spectating UI into the player’s PlayerGui, and have a script that’s parented to the GUI destroy the GUI when the player’s character spawns.

Here’s the .Died alternative I whipped up. This would go in a script parented to StarterCharacterScripts.

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

local HealthHitZero = false 
Player.Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	if HealthHitZero then return end
	local Value = Player.Character.Humanoid.Health
	if Value <= 0 then
		HealthHitZero = true
		task.wait(game.Players.RespawnTime)
		Player:LoadCharacter()
	end
end)
2 Likes

Thank you, This all worked, My huge problem for this is finally solved, thanks to you.

Obviously i had to fix a few UI scripts, but other than that, its all good. Thank you so much!

2 Likes