Hello there, So I'm trying to teleport a player to a certain part using HumanoidRootPart after the timer is over. But it doesn't seem to work.
Here is the script:
local roundLength = 5 local intermissionLength = 5 local InRound = game.ReplicatedStorage:WaitForChild("inRound") local Status = game.ReplicatedStorage:WaitForChild("Status") local LobbySpawn = game.Workspace.LobbySpawn local GameAreaSpawn = game.Workspace.GameAreaSpawn InRound.Changed:Connect(function() wait(1) if InRound.Value == true then for _, player in pairs(game.Players:GetChildren()) do local char = player.Character char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame end else for _, player in pairs(game.Players:GetChildren()) do local char = player.Character char.HumanoidRootPart.CFrame = LobbySpawn.CFrame end end end) local function roundTimer() while wait() do wait(4.5) for i = intermissionLength, 1, -1 do InRound.Value = false wait(1) Status.Value = "Next minigame in: ".. i .."" end wait(4.5) for i = roundLength, 1, -1 do InRound.Value = true wait(1) Status.Value = "Time left: ".. i .." seconds!" end end end spawn (roundTimer)
I did a research and tried to Google it but nothing seems to work. Thank you!
When setting a CFrame value you need to set it to the "CFrame.new" data type. Example:
char.HumanoidRootPart.CFrame = CFrame.new()
CFrame accounts for both position and orientation, so when you set something else to a CFrame you need to account for this. If I were you I would do
``char.HumanoidRootPart.CFrame = CFrame.new(GameAreaSpawn.Position)
That will set only the position of the player if you wanted to also set their orientation just add another value to the argument section.
I'm pretty new to Lua scripting, but as far as I can tell that's your problem, but I may have missed something.