Hello, I am trying to make the specific player teleport who has the Value to true. It currently teleports everyone. Btw it is in a normal script.
local roundLength = 5 local IntermissionLength = 20 local InRound = game.ReplicatedStorage.InRound local Status = game.ReplicatedStorage.Status local LobbySpawn = game.Workspace.LobbySpawn local GameAreaSpawn = game.Workspace.GameAreaSpawn local ReplicatedStorage = game:GetService("ReplicatedStorage") InRound.Changed:Connect(function() if InRound.Value == true then for i, player in pairs(game.Players:GetChildren()) do local char = player.Character if player.JoinRound.Value == true then char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame end end else for i, player in pairs(game.Players:GetChildren()) do local char = player.Character if player.JoinRound.Value == true then char.HumanoidRootPart.CFrame = LobbySpawn.CFrame player.PlayerGui.JoinRound.TextButton.Text = "Join" player.JoinRound.Value = false end end end end)
Sadly a local script can't change what a server script sees, luckily we have something called remotes. Add a remote event in ReplicatedStorage named RoundSpawn
--Normal Script/ Server Script--
local roundLength = 5 local IntermissionLength = 20 local InRound = game.ReplicatedStorage.InRound local Status = game.ReplicatedStorage.Status local LobbySpawn = game.Workspace.LobbySpawn local GameAreaSpawn = game.Workspace.GameAreaSpawn local ReplicatedStorage = game:GetService("ReplicatedStorage") ReplicatedStorage:WaitForChild("RoundSpawn").OnServerEvent:Connect(function(IsInRound,DoJoinRound) if IsInRound then for i, player in pairs(game.Players:GetChildren()) do local char = player.Character if player.JoinRound.Value == true then char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame end end else for i, player in pairs(game.Players:GetChildren()) do local char = player.Character if DoJoinRound then char.HumanoidRootPart.CFrame = LobbySpawn.CFrame player.PlayerGui.JoinRound.TextButton.Text = "Join" end end end end)
now in the local script, this is the line to fire, you can copy and paste each line depended on the action
--If they are supposed to spawn ReplicatedStorage:WaitForChild("RoundSpawn"):FireSever(true,false) -- to go to lobby ReplicatedStorage:WaitForChild("RoundSpawn"):FireSever(false,true)