Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

?Round System, making a specific player teleport?

Asked by
Zelt3q 31
3 years ago

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)

1 answer

Log in to vote
0
Answered by
FirezDevv 162
3 years ago
Edited 3 years ago

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)

Ad

Answer this question