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

ScreenGUI Works in Studio But Will Not Work in the Game Itself?

Asked by 6 years ago

I haven't figured out what is going wrong in my game and I've been searching for about 2 hours now and I can't figure anything out. I have a click detector set up to a Screen GUI that works in studio but will NOT work in game. I don't know what the problem is and I really need this to work

When I use play here it works fine but when I use the local server option it doesn't and there is nothing in the F9 menu that tells me about it.

I have a regular script running the screen gui where it opens the frame while there is a local script running the close button. I believe there is nothing wrong with the local script so i'm just going to include the normal script.

Here is my code.

local function click(player) player.PlayerGui.Paper1ScreenGui.Frame.Visible = true end script.Parent.ClickDetector.mouseClick:connect(click)

I don't know why it's jumbled up but I don't think that matters all too much. This is my first time asking a question on here. One other thing, I also want this to work for just one player when they click it so it'll only show up on that one player's screen when you he/she clicks it

0
you cant set a gui from a serverscript you need an event mattchew1010 396 — 6y

1 answer

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

It "works" in Studio because you used Play Solo. In that mode, the client and server are not separated, this is why LocalScripts may access things like ServerStorage or Scripts accessing LocalPlayer. Use local servers instead, as clients and server are separated there.

That aside, it didn't work because the server can't modify objects in PlayerGui unless placed by it. But the server shouldn't be touching that anyway. You will need a RemoteEvent.

-- LocalScript under your Frame
local remote = game:GetService("ReplicatedStorage").ShowGui
-- I named it ShowGui, name it whatever tho

remote.OnClientEvent:Connect(function()
    script.Parent.Visible = true
end)

Server:

local remote = game:GetService("ReplicatedStorage").ShowGui

local function click(player) 
  remote:FireClient(player) -- player is the client to fire to
end 

script.Parent.ClickDetector.MouseClick:Connect(click)

On a side note, mouseClick and connect are deprecated, use MouseClick and Connect instead.

0
how do you do a local server mattchew1010 396 — 6y
0
local servers you go to TEST and then where it has emulator and everything. User#19524 175 — 6y
Ad

Answer this question