Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ScreenGui Frame Visible Parameter doesn't work. Why?

I have a problem. There is a button representing a part. When you click on it, the GUI appears for the one who pressed the button. The matter is that all this works perfectly in ROBLOX STUDIO. But the Visible parameter does not change in the game itself.

There is code in Script (not localscript)

function chooseSong(player)
	script.Parent.BrickColor = BrickColor.Red()
	local person = player.PlayerGui
	script.Disabled = true
	if player.leaderstats.Coins.Value >= 1000 then
	script.Parent.Parent.SongDisplay.SurfaceGui.TextLabel.Text = player.Name.. " chooses music..."
	player.PlayerGui.Sound.Frame.Visible = true -- This is doesn't work in ROBLOX Game, but works in ROBLOX STUDIO. There are no errors in the console.
	else
	print("Nope!")
	script.Disabled = false
	end
end
script.Parent.ClickDetector.MouseClick:Connect(chooseSong)

5 comments

0

Once the script is disabled, the rest will not execute.

0

It's best to use a LocalScript for a GUI object.

0

Do not pay attention to script.Disabled. How to use Localscript? At me this script works only in Script. If the same script is added to Localscript, then there is no effect.

0

remoteevents exist for such exceptions

0

Yes to above, you need a local script and to clone the GUI to the PlayerGUI

2 answers

Adding to above, the server side script might look something like this...

local RemoteEvent = game.ReplicatedStorage.RemoteEvent --name and put in RS

function onTouch(hit)
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
         RemoteEvent:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
    end
end

script.Parent.Touched:connect(onTouch)

For the local script, try...

local RemoteEvent = game.ReplicatedStorage.RemoteEvent --name should match the RemoteEvent you're firing in the server script.

local player = game.Players.LocalPlayer

function ShowGui()
    local gui = game.ReplicatedStorage.GUI_NAME:clone() --whatever you named it
    if (not player.PlayerGui:FindFirstChild(gui.Name)) then
        gui.Parent = player.PlayerGui
    end
end

RemoteEvent.OnClientEvent:connect(ShowGui)

1 comment

0

Doesn't work.

function chooseSong(player)
    if player.leaderstats.Coins.Value >= 1000 then
    player.PlayerGui.Sound.Frame.Visible = true -- This is doesn't work in ROBLOX Game, but 
end
end
script.Parent.ClickDetector.MouseClick:Connect(chooseSong)

A simplified version of what I want to implement. It is with the help of CLICK that the visibility parameter is changed to "true"

This discussion is preserved as it was. New answers, comments, and votes are closed.