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

My gui wont change and other things??

Hello i need some help my gui wont change and the script is basicly not working

local button = script.Parent
local ExplosionOutOfBarrel = script.Parent.Parent.Partofexplode.Explosion
local ExplosionSoundOutofThebarrel = script.Parent.Parent.Partofexplode.ExplosionSound
local ExplodsionLight = script.Parent.Parent.Partofexplode.ExplosionLight
local SmokeyBoi = script.Parent.Parent.Partofexplode.Smoke
local AmountOfBombsleft = script.Parent.AmountOfBombs
local GuiOfBombs = game.StarterGui.ScreenGui.ShowBombs
local Xplode1 = script.Parent.Parent.ExplosionPart1.Explosion1
local Xplode2 = script.Parent.Parent.ExplosionPart2.Explosion2
local PartThatOofs = script.Parent.Parent.PartThatGoesBoom

local function BombGoOff()
	button.BrickColor = BrickColor.new("Really red")
	button.ClickDetector.MaxActivationDistance = 0
    ExplosionSoundOutofThebarrel:Play()
    Xplode1.Visible = true
    PartThatOofs.Transparency = 1
    PartThatOofs.CanCollide = false
	AmountOfBombsleft.Value = AmountOfBombsleft.Value - 1
	SmokeyBoi.Enabled = true
	ExplosionOutOfBarrel.Visible = true
	ExplodsionLight.Brightness = 7
	wait(0.78)
	ExplodsionLight = 0
	wait(15)
	SmokeyBoi.Enabled = false
	PartThatOofs.Transparency = 0
	PartThatOofs.CanCollide = true
	wait(1)
	button.BrickColor = BrickColor.new("Shamrock")
	button.ClickDetector.MaxActivationDistance = 32
	GuiOfBombs.Text = "".. AmountOfBombsleft.. "Bombs left!"
end

local function MakeSureItisntBelow()
	if AmountOfBombsleft.Value <= 0 then
		game.Players:ClearAllChildren()
		AmountOfBombsleft.Text = "No More Bombs Left. Join a Different server"
	end
end


script.Parent.ClickDetector.MouseClick:Connect(function()
    BombGoOff()
	MakeSureItisntBelow()
end)

while true do
	MakeSureItisntBelow()
end

2 comments

0

you should keep line 3 as one string

0

your code in general is junky and super messy, no wonder it won't do anything. Re-write it.

2 answers

  1. StarterGui will only replicate into PlayerGui when the player joins/resets. If you want to change the GUI when the player clicks on the button, change the PlayerGui, not StarterGui. So on line 7, change it to this (make sure this is in a LocalScript too:
local GuiOfBombs = game.Players.LocalPlayer.PlayerGui.ScreenGui.ShowBombs
  1. Don't use a click detector in a GUI. Just use MouseButton1Click. Example:
script.Parent.MouseButton1Click:Connect(function()

You aren't even using WaitForChild for those variables since they don't immediately load when a game starts. Instances take time to load. You may get an output error is not a valid member. Please use WaitForChild for those instances to load properly and then tell us the errors you're facing.

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