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

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

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

✓ Accepted answer

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)


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!

1 comment

0

I appreciate the fast response. I inserted this code and the GUI doesnt show, but there are no error msgs

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)

1 comment

0

It needs to be a server script instead of a local script or else the system doesn't work.

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