Hello Devs!
I was testing my game and usually during respawn i see flashes of other checkpoints (During the period between the death and respawn of the character).
Here is a video of the problem.
thats just roblox you cant do anything about it
Does this happen in every game then?
Thanks For The Reply!
I believe that is the default Roblox damage effect being applied whenever your character get’s damaged.
A workaround to this would be disabling the health UI ( via game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
), but you will need to make your own health bar if you choose to go this route.
Thanks for the reply,
But the thing is that these flashes always occur in the direction I would spawn if I were on some other checkpoint.
Oh, my bad I misinterpreted the issue that you were proposing. Analyzing it frame by frame, it seems that the player very quickly gets repositioned on spawning, causing a sort of “flashing” effect. Do you have any scripts that alter the behavior of player spawning? I don’t think that’s default Roblox behavior, and i’m unable to do any testing as i’m not on my computer.
I did add a leaderstats script. Do u think that is what’s causing the issue?
I don’t think leaderstats would have an effect like that. It would have to be something regarding your respawn method. How do you handle checkpoint respawning?
This problem is probably from moving the character right after it’s respawned.
The character spawns in one location, and that location is rendered, then is quickly moved to a different location and that different location is rendered.
You just need to fix up your teleport on respawn code. If you send the code that moves the character I can probably help you.
Edit:
Yeah this is the problem:
Frame:
Next (ish) frame:
The problem was identified and I’ll help explain the solution.
One solution is to simply make teams for checkpoints, and make spawns for said checkpoints. After doing that, you would simply set the players team any time they hit a checkpoint. But this makes the default leaderboard fill up very fast.
Another solution is to skip teams and just use the basic
SpawnLocation
. This prevents the leaderboard from getting filled with a bunch of teams, and is relatively straightforward. This sounds confusing at first, probably, but I’ll elaborate.You see, the Player instance has this neat little property called
RespawnLocation
that only accepts aSpawnLocation
datatype that is either: A. Neutral or B. the same Team Color.For our use case, we’d want a Neutral spawn position for each checkpoint, and when a user hits the checkpoint, update their
RespawnLocation
to thatSpawnLocation
. And that would fix your issue.
Now for the final solution:
Just don’t kill the player when they touch a kill brick or otherwise fail.Instead, teleport them back to the start.Simple enough, and makes your game overall cleaner.
It reduces repetitive creation of instances (Characters + Accessories) and makes game quality better.
You can instantly get back into the flow if you mess up, without needing to wait for respawn.
I Really like the idea of the teleportation. Will surely add it.
Thanks For Your Reply
Basically the script that is given changes the number in the leader stats to the number given to the stage, lets assume its 2, so whenever a player dies he respawns on the checkpoint numbered 2.
local checkpoints = workspace:WaitForChild("Checkpoints")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local v = Instance.new("IntValue")
v.Name = "Stage"
v.Value = 1
v.Parent = leaderstats
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
wait()
char:MoveTo(checkpoints[v.Value].Position)
hum.Touched:Connect(function(hit)
if hit.Parent == checkpoints then
if tonumber(hit.Name) == v.Value +1 then
v.Value = v.Value +1
end
end
end)
end)
end)
Thanks for helping out mate!
This is the script that tells the game which checkpoint to respawn on:
local checkpoints = workspace:WaitForChild("Checkpoints")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local v = Instance.new("IntValue")
v.Name = "Stage"
v.Value = 1
v.Parent = leaderstats
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
wait()
char:MoveTo(checkpoints[v.Value].Position)
hum.Touched:Connect(function(hit)
if hit.Parent == checkpoints then
if tonumber(hit.Name) == v.Value +1 then
v.Value = v.Value +1
end
end
end)
end)
end)
I think this should fix the problem.
plr.CharacterAdded:Connect(function(char)
local humanoidRootPart = char:WaitForChild("HumanoidRootPart")
while not char:IsDescendantOf(Workspace) do
char.AncestryChanged:Wait()
end
task.wait()
humanoidRootPart.CFrame = checkpoints[v.Value].CFrame + Vector3.new(0, 3.5, 0)
I’ll test that really fast though, I don’t recall the exact things you need to wait for before moving the character.
Also, where do you spin the character? I don’t think MoveTo rotates the character, but it looks like your character gets rotated.
Edit: Yep think that code works.
Edit:
Yeah. I was wondering where that code was though, that code also is probably delayed. Replacing the section with the new code should solve that though.
Should I replace this part of the script with your script?
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
wait()
char:MoveTo(checkpoints[v.Value].Position)
The character rotates cause in some places the spawn location is rotated i.e. the front face points towards the left. (will fix that shortly).
Thanks for helping me out!