So i made two buttons, which will make the player's Respawn change when ever Clicked. The problem is that I have two kinds of Respawns in my game, My game is a combination with a Tycoon and an Obby, so there's Respawns for the Obby and Respawns for the Tycoon. And i want to make the player choice where ever he wants to spawn. But for some reason my code doesnt work, i havent ever messed with player RespawnLocation so i'll need your guys help here!

Set Tycoon spawn point:

local players = game:GetService("Players")
local obbyv =  script.Parent.Parent.ObbyButton.Value
local tycoonv =  script.Parent.Value
local Teams = game:GetService("Teams")`
	script.Parent.MouseButton1Click:Connect(function(plr)
	plr = players.LocalPlayer	
	if plr.Team == Teams.Red then

		obbyv.Value = false
		tycoonv.Value = true	
		if tycoonv.Value == true then
			script.Parent.BackgroundColor3 = Color3.new(0.545098, 0.545098, 0)
			script.Parent.Shadow.BackgroundColor3 = Color3.new(0.282353, 0.282353, 0)
		
			script.Parent.Parent.ObbyButton.BackgroundColor3 = Color3.new(255, 0, 0)
			script.Parent.Parent.ObbyButton.Shadow.BackgroundColor3 = Color3.new(0.290196, 0, 0)
			plr.RespawnLocation = game.Workspace.Cloud1.SpawnLocation
		
		end
	
	end
end)

Set Obby spawn point:

local players = game:GetService("Players")
local Cpoints = game.Workspace.CheckPoints:GetChildren()
local obbyv =  script.Parent.Value
local tycoonv =  script.Parent.Parent.TycoonButton.Value
local Teams = game:GetService("Teams")
	script.Parent.MouseButton1Click:Connect(function(char)

		local player = players.LocalPlayer
		local leaderstats = player:FindFirstChild("leaderstats")
		local Stage = leaderstats:FindFirstChild("Stage")
		if player.Team == Teams.Red then
			obbyv.Value = true
			tycoonv.Value = false
			if obbyv.Value == true then
		
				player.RespawnLocation = Cpoints[Stage.Value]
			
			
				script.Parent.BackgroundColor3 = Color3.new(0.545098, 0.545098, 0)
				script.Parent.Shadow.BackgroundColor3 = Color3.new(0.282353, 0.282353, 0)

				script.Parent.Parent.TycoonButton.BackgroundColor3 = Color3.new(255, 0, 0)
				script.Parent.Parent.TycoonButton.Shadow.BackgroundColor3 = Color3.new(0.290196, 0, 0)
	
			end
		end


	end)

Also the leaderstats code for the stages maybe there's an error there idk:

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"

	local points = Instance.new("IntValue",leaderstats)
	points.Name = "points"
	points.Value = 0

	local Stage = Instance.new("IntValue",leaderstats)
	Stage.Name = "Stage"
	Stage.Value = 0

	local Cpoints = game.Workspace.CheckPoints

	player.CharacterAdded:Connect(function(char)
		local hum = char:FindFirstChild("Humanoid")
		wait()
		char:MoveTo(Cpoints[Stage.Value].Position)
		hum.Touched:Connect(function(hit)
			if hit.Parent == Cpoints then
				if tonumber(hit.Name) == Stage.Value + 1 then
					Stage.Value = Stage.Value + 1
				end
			
			end
		end)
	end)

end)

2 comments

0

are there any errors?

0

make sure SpawnLocation.TeamColor is set to the Player.TeamColor or SpawnLocation.Neutral is set to true