Basically the script below should make the alarm stop once it meets the requirements but it's not doing it. Anyone mind helping?
local alarm = Instance.new('Sound') alarm.Parent = script.Parent alarm.Name = "Alarm" alarm.SoundId = "rbxassetid://130821037" alarm.Looped = true alarm.MaxDistance = "10000" local size = math.random(10 , 30) local heat = math.random(10 , 20)-- change if you wish to while true do wait(5) if script.Parent.Fire.Enabled == false then wait(math.random(1 , 10)) -- change script.Parent.Fire.Size = size script.Parent.Fire.Heat = heat script.Parent.Fire.Enabled = true script.Parent.Parent.other.Fire.Size = size script.Parent.Parent.other.Fire.Heat = heat script.Parent.Parent.other.Fire.Enabled = true script.Parent.Parent.other2.Fire.Size = size script.Parent.Parent.other2.Fire.Heat = heat script.Parent.Parent.other2.Fire.Enabled = true script.Parent.Parent.other3.Fire.Size = size script.Parent.Parent.other3.Fire.Heat = heat script.Parent.Parent.other3.Fire.Enabled = true script.Parent.Parent.Parent.Parent.StarterGui.ScreenGui.TextLabel.Text = "Fire" wait(5) print ("HOUSE FIRE!") size = script.Parent.Fire.Size + math.random(1 , 10) -- change this to what ever you want alarm:Play() elseif script.Parent.Fire.Enabled == false then if alarm.IsPlaying == true then alarm:Stop() end end end
The elseif is not running because the conditions for stopping the alarm are the same as the one to set the fire.
Look at your script!
See that
if script.Parent.Fire.Enabled == false then
and that
elseif script.Parent.Fire.Enabled == false then
over there?
Well, if fire is false, then the first one is always triggered because it's the first. If the fire is true, none will be triggered. So, you most pick one for each.
They can't be both == false
, one of them should be == true
So, I'll suppose that you should modify the first "if then" so that it's triggered when it's true, and leave the second as how it is. (Or maybe the hole way wrong, It's your script, I don't know how do you want it to work!)
local alarm = Instance.new('Sound') alarm.Parent = script.Parent alarm.Name = "Alarm" alarm.SoundId = "rbxassetid://130821037" alarm.Looped = true alarm.MaxDistance = "10000" local size = math.random(10 , 30) local heat = math.random(10 , 20) while true do wait(5) if script.Parent.Fire.Enabled == true then wait(math.random(1 , 10)) -- change script.Parent.Fire.Size = size script.Parent.Fire.Heat = heat script.Parent.Fire.Enabled = true script.Parent.Parent.other.Fire.Size = size script.Parent.Parent.other.Fire.Heat = heat script.Parent.Parent.other.Fire.Enabled = true script.Parent.Parent.other2.Fire.Size = size script.Parent.Parent.other2.Fire.Heat = heat script.Parent.Parent.other2.Fire.Enabled = true script.Parent.Parent.other3.Fire.Size = size script.Parent.Parent.other3.Fire.Heat = heat script.Parent.Parent.other3.Fire.Enabled = true script.Parent.Parent.Parent.Parent.StarterGui.ScreenGui.TextLabel.Text = "Fire" -- this will not work. wait(5) print ("HOUSE FIRE!") size = script.Parent.Fire.Size + math.random(1 , 10) alarm.Playing = true elseif script.Parent.Fire.Enabled == false and alarm.Playing == true then alarm.Playing = false end end
This might be a better version. Hope it works.
In addition, in script.Parent.Parent.Parent.Parent.StarterGui.ScreenGui.TextLabel.Text = "Fire"
, this will not work if you run this game in Roblox (not studio), it is because changing the starterGui
is just changing the Gui that gives to player upon their arrival to the game. You will need a localscript
in order to change the player that is ALREADY in the game. If you need help transporting messages from this script to local script, check this wiki: http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions
Hope it works!