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

Why is this script not teleporting any player?

Asked by 5 years ago

I'm trying to make that the players will teleport when ChosenGamemode's text is "Free For All Was Chosen" or "Death Match Was Chosen" but it doesn't teleport any player and it doesn't change the text back to "Gamemode Was Chosen" and it doesn't disappear, It's because it doesn't make it through the player teleportation.

[Edit: I have no errors in output and make sure to check https://scriptinghelpers.org/questions/61874/why-is-this-script-not-teleporting-any-player, It's my other post about this]

Script:

for i, players in pairs(game.Players:GetChildren()) do
    local PlrGui = players.PlayerGui
    local RoundSystem = PlrGui.RoundSystem
    local Frame = RoundSystem.ChosenGamemode
    local ChosenGamemode = Frame.ChosenGamemode

    local Target = CFrame.new(0, 50, 0)

    while Frame.Visible == true do
        wait(0.1)

        if ChosenGamemode.Text == "Free For All Was Chosen" then
            wait(4)

            -- Teleport Players

            players.Character.HumanoidRootPart.CFrame = Target + Vector3.new(0, i * 5, 0)

            ChosenGamemode.Text = "Gamemode Was Chosen"
            Frame.Visible = false
        end

        if ChosenGamemode.Text == "Death Match Was Chosen" then
            wait(4)

            -- Teleport Players

            players.Character.HumanoidRootPart.CFrame = Target + Vector3.new(0, i * 5, 0)

            ChosenGamemode.Text = "Gamemode Was Chosen"
            Frame.Visible = false
        end
    end
end

(This script is a local script, I tried doing it in a script and the script is kinda glitched because it's long)

I would really appreciate it if you help me, Plus I'll accept your answer and we both make reputation from that.

Thanks, MajinBluee

1 answer

Log in to vote
0
Answered by 5 years ago

Depending on if you're in Filtering Enabled or not, if you are, then you wouldn't be able to edit the character's position from a Local Script. Also you wouldn't be able to get other player's PlayerGuis and see their content either since you would need to go from Client to Server to Other Client. To fix that you would need to set up some Remote Events to change the player's character data on the server side. If your place is not Filtering Enabled, then my only other idea of why it's not working would be on line 2, depending on when you are running that loop, not all player's PlayerGuis may be loaded. For example if someone just joined and you run that loop, chances are it might not be loaded in time. To fix that you would need to do players:WaitForChild("PlayerGui").

0
It doesn't work, But thanks for being kind and helping me with my problem. MajinBluee 80 — 5y
Ad

Answer this question