Why does my GUI only work in studio but not in the actual game

Hi there! So what I am trying to do is display an Image on an Image Label, thing is, everything works in Studio testing but not when im actually in the game.

Below are the first scripts, reminder, they work in studio but not in-game

Script 1 in StarterGui
script.Parent.Board_1.TextButton.MouseButton1Click:Connect(function()
	
	local Image = workspace.White_Boards.White_Board_1.SurfaceGui.ImageLabel
	
	Image.Image = "rbxassetid://".. script.Parent.Board_1.ID.Text
	
end)
Script in StarterPlayerScripts
local Players = game:GetService("Players")
local GUI = Players.LocalPlayer.PlayerGui:WaitForChild("Board_1")

local Click_1 = workspace.White_Boards.White_Board_1:WaitForChild("ClickDetector")

Click_1.MouseClick:Connect(function()
	
	print("Clicked")
	
	GUI.Enabled = true
	
end)

Edit: The print does work, as I see in console image

2 Likes

Do you have team-create on? If so, check for uncommitted drafts.

1 Like

You have to use FilteringEnabled for it to work in a game. You’re making adjustments to the server through the client and that’s not allowed. You must have the server change the image. I believe this might be of use for you.

I do believe that this is not true, as he should see the change on the client.

Yes, but it’s still making adjustments to the server through the client so it won’t be visible to other players, it’ll only be visible to him. I’m not sure if that’s what he wants, as he didn’t specify.

2 Likes

You cannot make game.Players.LocalPlayer a variable in a server-sided script. You can also not detect MouseClick from a ClickDetector through a client-sided script. There is a way you can enable a GUI for a player when a ClickDetector is clicked, and I’ve shown a quick example below.

local function click(player)
	local GUI = player.PlayerGui:WaitForChild("Board_1")
	print("Clicked")
	GUI.Enabled = true
end

local Click_1 = workspace.White_Boards.White_Board_1:WaitForChild("ClickDetector")
Click_1.MouseClick:Connect(click)

Hopefully this was helpful.

1 Like

For this to occur, one of three things must have happened.

FilteringEnabled wasn’t used. For this, search the DevForum for posts using FilteringEnabled.

Team Create scripts weren’t applied. For this, go into the settings of your game and turn team create off or right click on all your scripts from the top bar and click apply edits.

You used the wrong type of script. For this, always use a LocalScript. In some cases you can use a regular Script, but I wouldn’t worry about trying to mess with that.

I hope I helped.