You should be going the right path with whatever this is. But, you’re trying to access the Disabled property of a Model? That’s not even a thing? Maybe you should consider handling it like the other events by cloning it into the workspace and destroying it after the event period.
The script that performs the events is OK. But you’ll need to find a way to implement these events somehow, to make them do something.
Perhaps you can add a script in each event model that executes the actions needed, and it is automatically stopped when the event is destroyed. Then clone it into the workspace. You may have events that don’t need models, but you can just hardcode cases in the main script.
If the functionality of an event is the problem, you could’ve just made it the focus of this topic or made a new topic.
What do you need help with? Maybe just remove the IF condition for the nuke:
while true do
local rnd_wait = math.random(100, 300) -- Random wait time between events
local event = get_event_in_folder()
print(event.Name .. " event triggered!")
local clone_event = event:Clone()
clone_event.Parent = workspace
wait(event_period_time)
clone_event:Destroy()
-- Wait before the next event
wait(rnd_wait)
end
Then you can just add a script into the event model that performs the actions you need. It will automatically start and stop when the model is cloned and destroyed respectively.
This is the simplest I can go, otherwise I have no idea what you want me to do here.
All you have to do is replace the while loop in RandomEvent with the one I gave you.
If you need the nuke to do something, make a script in the Nuke model and add what you want.
If you need the UFO to do something else (it looks complete to me), modify your scripts, add new ones, test around.
local nuke = game.ServerStorage.Nuke
local sus = game.SoundService["Tactical Nuke Incoming!"]
local event_folder = game.ServerStorage.GameEvents
local event_peroid_time = 45
--[[while task.wait() do
local rnd_wait = math.random(100 , 300)
sus:Play()
wait(10)
nuke:Clone().Parent = workspace
task.wait(rnd_wait)
end ]]
local function get_event_in_folder()
local a = {}
for _, event in pairs(event_folder:GetChildren()) do
table.insert(a , event)
end
local random = math.random(1 , #event_folder:GetChildren())
return a[random]
end
while task.wait() do
local rnd_wait = math.random(100 , 300)
sus:Play()
task.wait(10)
local event = get_event_in_folder()
local clone_event = event:Clone()
clone_event.Parent = workspace
task.wait(event_peroid_time)
clone_event:Destroy()
task.wait(rnd_wait)
end
The RandomEvent script is already doing that (except the audio part – you’d move that into a script in the nuke)
Read up on SendNotification from SetCore to get notifications like in the game. I’m pretty sure that function is local only so you need to make use of RemoteEvents.
You’ll need to figure out how to spawn the meteorites yourself. All of this is too much for me to explain simply in this post. The Creator Hub documentation has good explanations.
function RNG(tableOfChances: {Instance: {number}})
local totalChance = 0
for _,chance in tableOfChances do
totalChance += chance
end
local rng = math.random(1, totalChance)
for option,chance in tableOfChances do
rng -= chance
if rng <= 0 then return option end
end
end
local events = {
[something] = number,
-- add more
}
while true do
local eventToOccur = RNG(events)
-- do event
local randomTimer = math.random(x,y)
task.wait(randomTimer)
end