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

Best way to have my disasters game execute the disasters?

Asked by 6 years ago

So I have a Survive The Disasters game, and I was wondering what is the most effective way to have these disasters happen. Here are my ideas:

  • Functions

So this one is the most simple. I have a Script in ServerScriptService (SSS), inside which is a loop which executes functions inside this script. This is very simple, however what if I want to execute two disasters at once? I mean, its not too flexible, is it.

  • RemoteEvents

This one is also quite simple, I have a script, and a RemoteEvent. Everytime the RemoveEvent is called, the script executes a disaster depending on the argument which was passed through the RemoveEvent.

Alternatively, I could have a separate RemoteEvent for each disaster, but I mean, thats not effective.

  • ModuleScripts

This might be the best idea. So I have ModuleScripts for each disaster in ServerStorage, and a Script in SSS which Clone()s these ModuleScripts, sets their parent to SSS, and then require()s them. The ModuleScript which was called would execute the disaster, and then delete itself.

  • Something else

Perhaps theres a more effective way, but I don't know. I have heard of BindableEvents, but idk about those and maybe they wouldn't be effective at all.

What do you think? What's the most effective way?

0
BindableEvents do not work to make games FE compatible. They are for server-server communication, and for client-client communication. Same for BindableFunctions. User#19524 175 — 6y

4 answers

Log in to vote
1
Answered by
MrMedian 160
6 years ago

The best way is to definitely use ModuleScripts. This is how I would do it: For each disaster, create a module that starts out like this (also put them all in a folder):

local Disaster = {}

function Disaster.StartDisaster(self)
    -- do disaster
end

return Disaster

and then in the main script, do this to start the disasters

local Disasters = DisasterFolder:GetChildren()
local DisasterModule = require(Disasters[math.random(1, #Disasters)])
DisasterModule:StartDisaster()
1
A disasters manager module to which other disaster modules can attach to would be useful while keeping the same API. User#5423 17 — 6y
0
true MrMedian 160 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

I am not the most efficient at scripting yet, but I would go with whatever you feel most comfortable with. And if you think something would work better learn more about it. Just experiment, may suck but would make the game more efficient. :D

Log in to vote
0
Answered by 6 years ago

Honestly I'm not sure but only you can figure out what works best for you, though if you want recommendations id just run it all under a script in serverscriptservice

Log in to vote
-1
Answered by 6 years ago

I Would Do It Like The Free Model Version Put The Disasters In a Table And Make The Script Put Them In The Workspace Heres A Example

local disasters = {"Soldier"}
local h = Instance.new("Hint",game.Workspace)
while true do
for i,v in pairs(disasters) do
h.Text = "Chooseing Disaster"
wait(3)
random = math.random(1,2)
disaster = game:GetService("Lighting"):FindFirstChild(v)
chosen = disaster:Clone()
chosen.Parent = game.Workspace
h.Text = disaster.Name.." Has Been Chosen"
wait(0.2)
h.Text = ""
for i = 25,1,-1 do
h.Text = "Time Left "..i
wait(1)
end
h.Text = "Times Up!"
wait(3)
game.Workspace:FindFirstChild(disaster.Name):Remove()
end
end

You Can Edit It If You Want

0
Uh... no. I try to avoid free models, and in my game the disasters don't get announced. Also, this script is very non-flexible; what if i wanna run two disasters at once? The "Hint" instance is deprecated, and "Chooseing"? Really? RiskoZoSlovenska 378 — 6y

Answer this question