Im trying to get a player to teleport back into the game after they have died. This is my script and I do not understand why it wont work.
Have you tried making a script where it spawns a teleported under the player when they die and then they just spawn back?
I have the script set up diffrently than that.
A local script is always listening for when a player dies.
This is the local script.
I call a remote event, passing in the player arugment. It connects to Replicated Storage, then to Server Script Service, where it then detects if they are ingame, or outofgame.
if they are not ingame, then it loops throgh the player spawns and teleports them to a random lobby spawn.
However this is where the elseif statement comes in and the rest of the script.
Sorry for my poor explanation. Im very tired and just don’t make sence. Heres what I mean = Make a script WITH A TELEPORTER.
Here’s what I mean
Player die = Teleporter spawns under dead body
Teleporter teleports player/Hominoid to Spawn or whatever.
If this is still poor explanation please let me know.
I can try what your explaining. However the human breaks apart so Im not sure that will work, they will just respawn in the lobby after teleporting back into the game. Because their dead bodyparts will be the onlything teleporting
Hmmm… Just try it because thats the best Idea I have and if it breaks you’re game/ doesnt work I take full responsibility for it.
I’ll try it out, if it does work. I’ll send in the script i made so other people can understand what you mean.
Also your script wont break my game. If theirs a bug, the debugger will catch it or i just load in a backup.
Alrighty thanks for trying im not very good at scripts but this is my best Idea.
local BlueSpawns = Spawns.BlueSpawns:GetChildren()
local spawns = {}
for BlueSpawn in ipairs(BlueSpawns) do
table.insert(spawns, BlueSpawn)
end
^ is equivalent to:
local BlueSpawns = Spawns.BlueSpawns:GetChildren() -- array of objects
local spawns = Spawns.BlueSpawns:GetChildren() -- also array of objects
also in
spawnpoint = BlueSpawns[choiceSpawn]
spawnpoint is nil everytime. That’s because BlueSpawns is an array and only has positive integer indexes or indicies. choiceSpawn is an object
local char = player.Character
if char then
player:LoadCharacter()
char.HumanoidRootPart.CFrame = spawnpoint.CFrame
end
^ doesn’t make sense because char will basically be nil after calling player:LoadCharacter()
I mean it’s not nil but player:LoadCharacter() will :Destroy() the previous character.
I would remove player:LoadCharacter() so it will teleport the current character.
But if you want to respawn them and then teleport the new character then say:
local char = player.Character
if char then
player:LoadCharacter()
end
char = player.Character or player.CharacterAdded:Wait()
char:WaitForChild("HumanoidRootPart")
char.HumanoidRootPart.CFrame = spawnpoint.CFrame
This worked! Also I did read up on your suggestion and made a cut-down version of the script. It’s much easier to read now! Here is the new script that works and functions.