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

Gui works in studio but in game?

Asked by
KenzaXI 166
9 years ago
local i = script.Parent
local map = workspace.Stadium.sa
local gui = script.Parent.Parent.Parent
local tele1 = game.Lighting.Tele1
function onButtonClicked()
    local plr = game.Players.LocalPlayer
    local character = plr.Character
if (plr and character ~= nil) then
    character:MoveTo(map.Position)  
    tele1:Clone().Parent = plr.PlayerGui
    script.Parent.Parent.Parent:Destroy()
end
    end
i.MouseButton1Down:connect(onButtonClicked)

I've re wrote it countless times, I browsed the wiki, This is my last resort! Thanks for any help.

0
Is it in a LocalScript? Muoshuu 580 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago
repeat wait() until game.Players.LocalPlayer
local i = script.Parent
local map = workspace.Stadium.sa
local gui = script.Parent.Parent.Parent
local tele1 = game.Lighting.Tele1
function onButtonClicked()
    local plr = game.Players.LocalPlayer
    local character = plr.Character
if (plr and character ~= nil) then
    character:MoveTo(map.Position)  
    tele1:Clone().Parent = plr.PlayerGui
    script.Parent.Parent.Parent:Destroy()
end
    end
i.MouseButton1Down:connect(onButtonClicked)

The difference between studio and in game mode is that in studio, the player loads immediately. In game, the player takes a little bit to load. So, if we keep waiting until the script detects a Player, this can be resolved.

0
Remember to mark as answer if it works. HungryJaffer 1246 — 9y
0
Thanks, KenzaXI 166 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Is it in a local script?

0
Please refrain from asking questions in answers. These belong inside the comments to the question. HungryJaffer 1246 — 9y

Answer this question