Spawn choice gui trouble

Im trying to make choose spawn gui. but it always spawns me at spawn 2. can someone tell me why. Im not trying to make a different remote event for every spawn.
Script in serverscriptservice

game.ReplicatedStorage.Spawn.OnServerEvent:Connect(function(player,spawn1, spawn2)
	
	if spawn2 then
		player.Character.HumanoidRootPart.Position = game.Workspace.Spawns.Spawn2.Position
	end
	if spawn1 then
		player.Character.HumanoidRootPart.Position = game.Workspace.Spawns.Spawn1.Position
	end
		
end)
local spawn1 = game.Workspace.Spawns.Spawn1

script.Parent.Activated:Connect(function(player)
	game.ReplicatedStorage.Spawn:FireServer(player, spawn1)
end)
local spawn2 = game.Workspace.Spawns.Spawn2

script.Parent.Activated:Connect(function(player)
	game.ReplicatedStorage.Spawn:FireServer(player, spawn2)
end)
1 Like

try this in the serverscriptservice script:

game.ReplicatedStorage.Spawn.OnServerEvent:Connect(function(player,spawn)
	player.Character.HumanoidRootPart.Position = game.Workspace.Spawns:FindFirstChild(spawn).Position
end)

You don’t need to sent the Player variable to the server, the server receives it always by default

Should look like this:

game.ReplicatedStorage.Spawn:FireServer(spawn2)

Also, the server should only receive 1 spawn



Instead, do something like this:

client:

server:


local Spawn1 = --here
local Spawn2 = --here

game.ReplicatedStorage.Spawn.OnServerEvent:Connect(function(Player, SpawnNumber)	

 if SpawnNumber == 1 then
  Player.Character.HumanoidRootPart.CFrame = Spawn1.CFrame

 elseif SpawnNumber == 2 then
  Player.Character.HumanoidRootPart.CFrame = Spawn2.CFrame

 end	

end)
2 Likes