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

Trying to make this GUI visible when the script is executed?

Asked by 8 years ago

Hello. I've been trying to make it so when this script is executed, it turns the Gui located in startergui visible. By default, I disabled the visible feature. I included a print statement after the visible code and it does print, however it doesn't show on your screen. I was wondering how can you make it so it shows on the players screen? Thanks!

Code:

01pop = script.Parent.Sound
02 
03function crash(hit)
04    if hit.Parent.Name == "Hammer" then
05        wait(0.1)
06        game.StarterGui.bankg.b1.Visible = true
07        game.StarterGui.bankg.b2.Visible = true
08        game.StarterGui.bankg.b3.Visible = true
09        print("gui visible")
10 
11        script.Parent.Transparency = 1
12        script.Parent.CanCollide = false
13        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 0.7
14        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = true
15        pop:Play()
View all 31 lines...

3 answers

Log in to vote
1
Answered by 8 years ago

this should work for a server script.

if it doesnt, let me know

01game.Players.PlayerAdded:connect(function(player))
02pop = script.Parent.Sound
03 
04 
05function crash(hit)
06    if hit.Parent.Name == "Hammer" then
07 wait(0.1)
08       player.Playergui.bankg.b1.Visible = true
09      player.Playergui.bankg.b2.Visible = true
10        player.Playergui.bankg.b3.Visible = true
11        print("gui visible")
12 
13        script.Parent.Transparency = 1
14        script.Parent.CanCollide = false
15        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 0.7
View all 33 lines...
Ad
Log in to vote
0
Answered by 8 years ago

Please, for the sake of scripting future, don't edit StarterGui unless necessary!!!!!! You can use loops to iterate through the players..

01pop = script.Parent.Sound
02 
03local function changeGui(boolean) --Lets make a function to change the GUI. In our case, "true"means visible, and "false" means invisible
04    for i,v in pairs(game.Players:GetPlayers()) do --Iterate through players
05        v:FindFirstChild("PlayerGui").bankg.b1.Visible = boolean
06        v:FindFirstChild("PlayerGui").bankg.b2.Visible = boolean
07        v:FindFirstChild("PlayerGui").bankg.b3.Visible = boolean
08    end
09end
10 
11function crash(hit)
12    if hit.Parent.Name == "Hammer" then
13        wait(0.1)
14    changeGui(true) --Visible
15        print("gui visible")
View all 33 lines...

StarterGui will ONLY update for player's who join or respawn after the change!

0
I appreciate the fast response. I inserted this code and the GUI doesnt show, but there are no error msgs alexduskthorn 40 — 8y
Log in to vote
-1
Answered by 8 years ago
Edited 8 years ago

Okay so don't use game.StarterGui. That doesn't do. If you a using a server script, change it to a local script.

01plr = game.Players.LocalPlayer
02pop = script.Parent.Sound
03 
04function crash(hit)
05    if hit.Parent.Name == "Hammer" then
06        wait(0.1)
07        game.StarterGui.bankg.b1.Visible = true
08        game.StarterGui.bankg.b2.Visible = true
09        game.StarterGui.bankg.b3.Visible = true
10        print("gui visible")
11 
12        script.Parent.Transparency = 1
13        script.Parent.CanCollide = false
14        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 0.7
15        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = true
View all 32 lines...
0
It needs to be a server script instead of a local script or else the system doesn't work. alexduskthorn 40 — 8y

Answer this question