I am making a mingame game and I can't teleport players to the right place, here is the code
Code in StarterPlayerScripts:
local RS = game:GetService("ReplicatedStorage")
local TF = RS:WaitForChild("TimeForever")
local TD = RS:WaitForChild("TD")
local function Time(Part)
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text -=1
if game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text == 0 and RS.Value == ("Lobby") then
local PN = script.Parent.Parent
game.Workspace(PN.Name).HumanoidRootPart.CFrame = Part.CFrame
PN:FindFirstChild("Roblox").Value = ("Start")
end
end
TF.OnClientEvent:Connect(Time)
code in normal scripts in serverScriptService: local Players = game.Players:GetPlayers() local GS = game.ReplicatedStorage.GameStatus local RS = game:GetService("ReplicatedStorage") local TF = RS.TimeForever GS.Value = ("Lobby") repeat wait() until #game.Players:GetPlayers() == 1 repeat TF:FireAllClients(TF) wait(1) for i, v in pairs(game.Players:GetPlayers()) do local R = v:FindFirstChild("Roblox") if not R == "Start" and i == #game.Players:GetPlayers() then
else if R == "Start" then local Result = math.Random(1,2) if Result == 1 then for i, v in pairs(Players) do game.Workspace(v.name).CFrame = math.Random(Vector3.new(258 or 248 or 238, 248, 258 or 248 or 238)) end elseif Result == 2 then for i, v in pairs (Players) do game.Workspace(v.name).CFrame = game.Workspace.FloodItis.CFrame end end end end end
until #game.Players:GetPlayers() == 0 . TF firing is for Intermission, it changes the Timer every second FloodItIs is a teleportation place for the minigame to begin Result is the result of math.Random to choose between minigames this code: math.Random(Vector3.new(258 or 248 or 238, 248, 258 or 248 or 238)) is for the swordfights mingame and flooditis is for the flood Escape minigame once All of the players ScreenGuis show 0 then It will start the code
PS if their is a better or cleaner way to make the timer too, it would be helpful if you mentioned it
i dont know how to use Cframe well so please tell me if i have errors