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:

pop = script.Parent.Sound

function crash(hit)
    if hit.Parent.Name == "Hammer" then
        wait(0.1)
        game.StarterGui.bankg.b1.Visible = true
        game.StarterGui.bankg.b2.Visible = true
        game.StarterGui.bankg.b3.Visible = true
        print("gui visible")

        script.Parent.Transparency = 1
        script.Parent.CanCollide = false
        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 0.7
        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = true
        pop:Play()

        wait(15)
        script.Parent.CanCollide = true
        script.Parent.Transparency = 0.5
        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 1
        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = false
        wait(0.1)
        game.StarterGui.bankg.b1.Visible = false
        game.StarterGui.bankg.b2.Visible = false
        game.StarterGui.bankg.b3.Visible = false
        else
        print ("Bank Working")
    end
end

script.Parent.Touched:connect(crash)

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

game.Players.PlayerAdded:connect(function(player))
pop = script.Parent.Sound


function crash(hit)
    if hit.Parent.Name == "Hammer" then
 wait(0.1)
       player.Playergui.bankg.b1.Visible = true
      player.Playergui.bankg.b2.Visible = true
        player.Playergui.bankg.b3.Visible = true
        print("gui visible")

        script.Parent.Transparency = 1
        script.Parent.CanCollide = false
        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 0.7
        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = true
        pop:Play()

        wait(15)
        script.Parent.CanCollide = true
        script.Parent.Transparency = 0.5
        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 1
        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = false
        wait(0.1)
       player.Playergui.bankg.b1.Visible = false
       player.Playergui.bankg.b2.Visible = false
        player.Playergui.bankg.b3.Visible = false
        else
        print ("Bank Working")
    end
end

script.Parent.Touched:connect(crash)


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..

pop = script.Parent.Sound

local function changeGui(boolean) --Lets make a function to change the GUI. In our case, "true"means visible, and "false" means invisible
    for i,v in pairs(game.Players:GetPlayers()) do --Iterate through players
        v:FindFirstChild("PlayerGui").bankg.b1.Visible = boolean
        v:FindFirstChild("PlayerGui").bankg.b2.Visible = boolean
        v:FindFirstChild("PlayerGui").bankg.b3.Visible = boolean
    end
end

function crash(hit)
    if hit.Parent.Name == "Hammer" then
        wait(0.1)
    changeGui(true) --Visible
        print("gui visible")
        script.Parent.Transparency = 1
        script.Parent.CanCollide = false
        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 0.7
        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = true
        pop:Play()
        wait(15)
        script.Parent.CanCollide = true
        script.Parent.Transparency = 0.5
        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 1
        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = false
        wait(0.1)
    changeGui(false) --Not visible
        else
        print ("Bank Working")
    end
end

script.Parent.Touched:connect(crash)

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.

plr = game.Players.LocalPlayer
pop = script.Parent.Sound

function crash(hit)
    if hit.Parent.Name == "Hammer" then
        wait(0.1)
        game.StarterGui.bankg.b1.Visible = true
        game.StarterGui.bankg.b2.Visible = true
        game.StarterGui.bankg.b3.Visible = true
        print("gui visible")

        script.Parent.Transparency = 1
        script.Parent.CanCollide = false
        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 0.7
        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = true
        pop:Play()

        wait(15)
        script.Parent.CanCollide = true
        script.Parent.Transparency = 0.5
        script.Parent.Parent.BrokenWindow["Broken Window"].Transparency = 1
        script.Parent.Parent.BrokenWindow["Broken Window"].CanCollide = false
        wait(0.1)
        plr.PlayerGui.bankg.b1.Visible = false
        plr.PlayerGui.bankg.b2.Visible = false
        plr.PlayerGui.bankg.b3.Visible = false
        else
        print ("Bank Working")
    end
end

script.Parent.Touched:connect(crash)
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