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

Local script help?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

This script is in a LocalScript and when I click on a TextButton then Frame does not get removed. This script only works in Studio and not in the real game.

--//Variables
plr = game.Players.LocalPlayer
plrGui = plr.PlayerGui.Note
Frame = plrGui.Frame
Tb = Frame.Close

--//Script
Tb.MouseButton1Click:connect(function()
    Frame:Destroy()
end)


1 answer

Log in to vote
1
Answered by 8 years ago
--//Variables
plr = game.Players.LocalPlayer
repeat wait() until plr.Character -- makes sure everything loads first
plrGui = plr.PlayerGui.Note
Frame = plrGui.Frame
Tb = Frame.Close

--//Script
Tb.MouseButton1Click:connect(function()
    Frame:Destroy()
end)



The line i added at the annotation mark makes sure everything loads, it works in studio because it loads instantly but in server scripts load before actual server stuff so latency issues emerge. I added it so it waits till the server loads the character.

Ad

Answer this question