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

Why won't my GUI create an explosion?

Asked by 9 years ago

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.

01local Explosive = game.Workspace.Model.Mechanism
02local Screen = Instance.new("ScreenGui")
03local Button = Instance.new("TextButton")
04Screen.Parent = game.StarterGui
05Button.Parent = Screen
06Button.Text = "FIRE!!"
07Button.Position = UDim2.new(0, 50, 0, 100)
08Button.Size = UDim2.new(0, 80, 0, 50)
09Button.BackgroundColor3 = Color3.new(200,0,0)
10function explode()
11    local ex = Instance.new("Explosion")
12    ex.BlastPressure = 99999999
13    ex.BlastRadius = 50
14    ex.Parent = Explosive
15    ex.DestroyJointRadiusPercent = 0
16    ex.Position = Explosive.Position
17end
18wait(1)
19Button.MouseButton1Down:connect(explode)

1 answer

Log in to vote
0
Answered by 9 years ago

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

here:

01local Explosive = workspace.Part
02 
03local player = game:GetService("Players").LocalPlayer
04local playergui = player.PlayerGui
05 
06local Screen = Instance.new("ScreenGui", playergui)
07local Button = Instance.new("TextButton", Screen)
08 
09Button.Text = "FIRE!!"
10Button.Position = UDim2.new(0, 50, 0.5, 0)
11Button.Size = UDim2.new(0, 80, 0, 50)
12Button.BackgroundColor3 = Color3.new(200,0,0)
13 
14Button.MouseButton1Down:connect(function()
15    local ex = Instance.new("Explosion",workspace)
16    ex.BlastPressure = 99999999
17    ex.BlastRadius = 50
18    ex.DestroyJointRadiusPercent = 0
19    ex.Position = Explosive.Position
20end)
Ad

Answer this question