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

Why won't my GUI create an explosion?

I am doing tests for a gun making simulator and I need a button to remotely detonate it, but the script I made won't work. It is in a local script and it does not give me any errors.

local Explosive = game.Workspace.Model.Mechanism
local Screen = Instance.new("ScreenGui")
local Button = Instance.new("TextButton")
Screen.Parent = game.StarterGui
Button.Parent = Screen
Button.Text = "FIRE!!"
Button.Position = UDim2.new(0, 50, 0, 100)
Button.Size = UDim2.new(0, 80, 0, 50)
Button.BackgroundColor3 = Color3.new(200,0,0)
function explode()
	local ex = Instance.new("Explosion")
	ex.BlastPressure = 99999999
	ex.BlastRadius = 50
	ex.Parent = Explosive
	ex.DestroyJointRadiusPercent = 0
	ex.Position = Explosive.Position
end
wait(1)
Button.MouseButton1Down:connect(explode)

1 answer

Parent it to workspace, and don't put the GUI in the StarterGui. Parent it to the local player.

here:

local Explosive = workspace.Part

local player = game:GetService("Players").LocalPlayer
local playergui = player.PlayerGui

local Screen = Instance.new("ScreenGui", playergui)
local Button = Instance.new("TextButton", Screen)

Button.Text = "FIRE!!"
Button.Position = UDim2.new(0, 50, 0.5, 0)
Button.Size = UDim2.new(0, 80, 0, 50)
Button.BackgroundColor3 = Color3.new(200,0,0)

Button.MouseButton1Down:connect(function()
	local ex = Instance.new("Explosion",workspace)
    ex.BlastPressure = 99999999
    ex.BlastRadius = 50
    ex.DestroyJointRadiusPercent = 0
    ex.Position = Explosive.Position
end)

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