Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't this custom spawn script work?

game.Players.PlayerAdded:connect(function(plr)
	
	plr.Character.Humanoid.Died:connect(function(died)
		if plr.TeamColor == BrickColor.new("New Yeller") then
		
	
		wait(6)
		died.Parent:MoveTo(game.Workspace.Custom1.Position)
		elseif plr.TeamColor == BrickColor.new("Toothpaste") then
			wait(6)
			died.Parent:MoveTo(game.Workspace.SpecialSpawn2.Position)
		elseif plr.TeamColor == BrickColor.new("Pink") then
			wait(6)
			died.Parent:MoveTo(game.Workspace.Custom3.Position)
		else
			print("The player that died isn't on any of the custom spawn teams, so they weren't teleported")
			
		end
	end)
end)

I have made this because I already used the 4 spawns ROBLOX gave us, which means if I duplicate it, and change its color, it won't teleport you to the spawn once you die. The problem with this script is that it won't teleport at all! The only part that works is the else part. Help?

3 comments

0

Whats Custom1, Custom2, Custom3? Are they bricks?

0

They are SpawnLocations.

2

The died connect has no parameters.

1 answer

game.Players.PlayerAdded:connect(function(plr)

	local function spawnchar(position) --function to spawn player
		local spawned
		repeat wait()
		if workspace:findFirstChild(plr.Name) and workspace[plr.Name]:findFirstChild("Humanoid") then
			if workspace[plr.Name].Humanoid.Health > 0 then
				spawned = true
			end
		end
		until spawned
		plr.Character:MoveTo(position)
	end

    plr.Character.Humanoid.Died:connect(function(died)
        if plr.TeamColor == BrickColor.new("New Yeller") then
		spawn(workspace.Custom1.Position)
        elseif plr.TeamColor == BrickColor.new("Toothpaste") then
		spawn(workspace.Custom2.Position)
        elseif plr.TeamColor == BrickColor.new("Pink") then
		spawn(workspace.Custom3.Position)
        else
            print("The player that died isn't on any of the custom spawn teams, so they weren't teleported")

        end
    end)
end)

try that, this will wait until the character spawns and teleport the character to the position.

2 comments

0

Are you sure this works? Did you test it?

0

I didn't test it, but it should work.

This discussion is preserved as it was. New answers, comments, and votes are closed.