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

Gui working in studio but its not working in game, Any solution? Codes included.

Asked by 6 years ago

Hello, im trying to make a soccer game with animated gui's and cool stuff. However, all the GUI's function as coded in Studio but nothing actually happen when i publish the game "Private" and try it out. As well as none of the buttons function ingame. "They don't even show"

Script location: game.StarterGui.Menu.MenuB.Script

If i wanna call it im using: game.Players.LocalPlayer.PlayerGui.Menu.MenuB.Script

Menu button code:

F = script.Parent.Parent.Frame
O = F.Frame
script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Frame.Visible = true
F.Position = UDim2.new(-1, -500, 0, 0)
O.Position = UDim2.new(0, -100, 0, 0)

wait(.3) 
F:TweenPosition(UDim2.new(0, 0, 0, 0), "In", "Quad", .4) 
O:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Back", 1) 
wait(.3)
script.Parent.Visible = false
script.Parent.Parent.Parent.PLLogo.Enabled = false
script.Parent.Parent.Parent.Player.Enabled = false
script.Parent.Parent.Parent.ScoreboardB.Enabled = false
script.Parent.Parent.Parent.ScoreboardA.Enabled = false
end)

1
connect is deprecated use Connect. But the problem is you used a Script so switch your script to a LocalScript and problem solved. ALWAYS have localscripts handle GUI User#19524 175 — 6y

1 answer

Log in to vote
2
Answered by
green271 635 Moderation Voter
6 years ago

Problem: GUI does not work in-game, but works in studio.

The reason why your script does not work is because you are you using a Script. Script's run on the server, and cannot access PlayerGUI's. LocalScript's are vice-versa, they only run in certain places. These are the player's Backpack, PlayerGui, Character and PlayerScripts. LocalScripts will also run in the ReplicatedFirst service.

You should have your LocalScript managing the GUI.

This is only true to live testing, which is why it will work in Roblox Studio but not online.

The solution:

Copy all your code and paste it into a localscript. Set the location to: game.Players.LocalPlayer.PlayerGui.Menu.MenuB

And another note, connect is deprecated. Use should be using Connect.

Ad

Answer this question