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

My Teleportation Script is working only occasionally? Can someone please help me?

Asked by 5 years ago

Hi! I have a Murder-Mystery style game, with a Teleportation Script. This script is suppose to wait until a TextLabel Changes, then teleport a player to a map. Then once it changes again, it's suppose to teleport back. I honestly don't know whats wrong with my script. It seems to work occasionally, as once I got it working, I downloaded a copy. Then the script broke again. So I booted up the copy, updated my game with it, STILL BROKE. I don't know If this is my fault or roblox's.

Script:

game.Players.PlayerAdded:Connect(function(player)
    while true do
    local Tab = {CFrame.new(-907, 5.4, -307); CFrame.new(-708, 73.4, -338); CFrame.new(-719, 73.4, -243); CFrame.new(-696, 55.4, -288); CFrame.new(-747, 6, -279); CFrame.new(-650, 5, -294); CFrame.new(-712, 8.6, -193); CFrame.new(-903, 5, -425); CFrame.new(-902, 8.6, -176); CFrame.new(-679, 55.4, -366); CFrame.new(-768, 60.2, -394); CFrame.new(-673, 38.6, -373); CFrame.new(-726, 38.6, -253); CFrame.new(-727, 55.4, -330)}
    local locationselected = Tab[math.random(1, #Tab)]
    local Spawnplates = {CFrame.new(19.511, 18.27, -42.511); CFrame.new(-31.86, 18.069, -18.085); CFrame.new(36.297, 19.375, -23.067); CFrame.new(-23.937, 18.17, -34.292); CFrame.new(-7.526, 18.27, -45.252); CFrame.new(-31.86, 18.069, -18.085); CFrame.new(37.096, 18.471, 9.724); CFrame.new(-35.261, 18.471, 2.364); CFrame.new(19.511, 18.27, -42.511)}
    local spawnselected = Spawnplates[math.random(1, #Spawnplates)]
    if player.PlayerGui:WaitForChild("ScreenGui").TextLabel.Changed then
    game.Workspace:WaitForChild(player.Name).Head.CFrame = locationselected
    if player.PlayerGui:WaitForChild("ScreenGui").TextLabel.Changed then
    game.Workspace:WaitForChild(player.Name).Head.CFrame = spawnselected
    wait()
    end
    end
    end
end)

Heres the only thing relating to the script in the server log. (statusbar used to be the named of the ScreenGui, before I changed it to ScreenGui) Dev Console Server Log: 18:58:40: --statusbar is not a valid member of PlayerGui Stack Begin Script 'ServerScriptService.MapTeleport' Line 7 Stack End

I think my game just isn't updating because there's no gui named statusbar anymore. Any help or thoughts is appreciated. I'm really starting to get desperate.

                                     -SBlank (pls no delete incapaz)
0
That is the worst tables i've ever seen lol. kittonlover101 201 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Your error is on lines 7 and 9. You’re trying to listen for the Changed event within an if statement, which is bound to throw you an error.

Format it like this:

PlayerGui.ScreenGui.TextLabel.Changed:Connect(function()
-- Code
end)
Ad

Answer this question