Hi, I am trying to make a self destruct that requires two panels to be interacted with(via ProximityPrompts) Within A Certain Timeframe of each other, The Prompt Should Change A BoolValue To True, And If The Other Panel’s Boolvalue Is Also True Then It Starts Its Stuff.
For Some Reason My Script Can’t Detect The BoolValues Changing, I Have Verified That They Do In Fact Change By Looking At Them In Explorer, Yet My Script Doesn’t Acknowledge It And Doesn’t Throw Any Errors.
I Have Spent All Day Changing The Code In Spots Trying To Get It To Work, But It Still Won’t. I Probably Overlooked Something But I Can’t Figure Out What.
The File Tree Looks Like This[
MainModel(Model)
|- MainScript(Script)
|- Armed1(BoolValue)
|- Armed2(BoolValue)
|- Frame(Union)
|- Emitter(Part)
|- Alarm(Sound)
|- Panel1(Part)
|- Interacted(Sound)
|- Arm(ProximityPrompt)
|- Deactivate(ProximityPrompt)
|- Script(Script)
|- Panel2
|- Interacted(Sound)
|- Arm(ProximityPrompt)
|- Deactivate(ProximityPrompt)
|- Script(Script)
|- Screen(Part)
|- SurfaceGui(SurfaceGui)
|- Frame(Frame)
|- TextLabel(TextLabel)]
This Is The Panel1 Script
local Armed1 = script.Parent.Parent.Armed1
local Armed2 = script.Parent.Parent.Armed2
local Prompt = script.Parent.Arm
local Debounce = false
local Interacted = script.Parent.Interacted
Prompt.Triggered:Connect(function()
if Debounce == false then
Debounce = true
Interacted:Play()
Armed1.Value = true
wait(2)
Armed1.Value = false
wait(2)
Debounce = false
end
end)
This Is The Panel2 Script
local Armed1 = script.Parent.Parent.Armed1
local Armed2 = script.Parent.Parent.Armed2
local Prompt = script.Parent.Arm
local Debounce = false
local Interacted = script.Parent.Interacted
Prompt.Triggered:Connect(function()
if Debounce == false then
Debounce = true
Interacted:Play()
Armed2.Value = true
wait(2)
Armed2.Value = false
wait(2)
Debounce = false
end
end)
And This Is The Main Script
--Locals--------------------------------------------------------------------------------------------
local Alarm = script.Parent.Emitter.Alarm
local TimeLeft = 300 --300 = 5 Minutes, 600 = 10 Minutes, 60 = 1 Minute
local Armed1 = script.Parent.Armed1
local Armed2 = script.Parent.Armed2
local Active = false
local Panel1 = script.Parent.Panel1
local Panel2 = script.Parent.Panel2
local Emitter = script.Parent.Emitter
local ScreenText = script.Parent.Screen.SurfaceGui.Frame.TextLabel
--Functions-----------------------------------------------------------------------------------------
function SelfDestructStart()
print("Starting Self Destruct")
Active = true
Alarm:Play()
Panel1.Arm.MaxActivationDistance = 0
Panel1.Deactivate.MaxActivationDistance = 10
Panel2.Arm.MaxActivationDistance = 0
Panel2.Deactivate.MaxActivationDistance = 10
print("Self Destruct Started")
end
function SelfDestructStop()
print("Stopping Self Destruct")
Active = false
Alarm:Stop()
Panel1.Arm.MaxActivationDistance = 10
Panel1.Deactivate.MaxActivationDistance = 0
Panel2.Arm.MaxActivationDistance = 10
Panel2.Deactivate.MaxActivationDistance = 0
print("Self Destruct Stopped")
end
--TimerResources------------------------------------------------------------------------------------
function Format(Int)
return string.format("%02i", Int)
end
function convertToMS(Seconds)
local Minutes = (Seconds - Seconds%60)/60
Seconds = Seconds - Minutes*60
return Format(Minutes)..":"..Format(Seconds)
end
--MainTimerLoop-------------------------------------------------------------------------------------
while true do
if Active == true then
local Time = convertToMS(TimeLeft)
ScreenText.Text = Time
TimeLeft = TimeLeft - 1
else
TimeLeft = 300
end
if TimeLeft == 0 then
Active = false
ScreenText.Text = "Self Destruct Inactive"
local ex = Instance.new("Explosion")
ex.BlastPressure = math.random(3e5,5e5)
ex.BlastRadius = 300
ex.Position = Emitter.CFrame
ex.Parent = game.Workspace
game.Debris:AddItem(ex,2)
end
wait(1)
end
--FunctionCallers-----------------------------------------------------------------------------------
Armed1.Changed:Connect(SelfDestructStart)
Armed2.Changed:Connect(SelfDestructStart)
Panel1.Deactivate.Triggered:Connect(SelfDestructStop)
Panel2.Deactivate.Triggered:Connect(SelfDestructStop)
This is my first post so sorry if i did anything wrong, I made the place uncopylocked so you can try to help, Any help would be great, as I don’t know where to go from here.