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

i wanted to make gui visible by a button it didnt work. Can someone help?

Brick = script.Parent Sound = Brick.Sound

function onClicked() Sound:Play() game.StarterGui.ScreenGui.Frame.Visible = true end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

2 answers

You changed the StarterGui Guis. StarterGui guis are only viewable by server and what we see is PlayerGui. Heres a sample below:

game.Players.Thelodomir_320.PlayerGui.ScreenGui.Frame.Visible = true

To fit in your script, you need to access to PlayerGui. By accessing PlayerGui you need to have the player. You can get player parameter with PlayerAdded event. You can access it with any script.

game:GetService("Players").PlayerAdded:Connect(function(player) -- to get the player parameter
	local Brick = script.Parent
	local Sound = Brick.Sound

	function onClicked()
		Sound:Play()
		player:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
	end
	
	Brick.ClickDetector.MouseClick:Connect(onClicked)
end)

1 comment

0

ooooh

Hm. Well I say i have the solution for that.

You did the sound and the playing sound wrong.

Brick = script.Parent.Brick.Sound


local function OnClick()
	Brick.Playing = true
	game.StarterGui.ScreenGui.Frame.Visible = true
end

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

not

Brick = script.Parent Sound = Brick.Sound

function onClicked() 
	Sound:Play() game.StarterGui.ScreenGui.Frame.Visible = true 
	game.StarterGui.ScreenGui.Frame.Visible = true
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

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