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

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

Asked by 2 years ago

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

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago

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)
0
ooooh Thelodomir_320 5 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

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)

Answer this question