Okay so should I make 6 seperate buttons controlling all the lasers? That way it would be easier (for me) to make the temp system.
I can make you an exception. I got permission from the game owner. If anyone else want’s to test it, i’ll send a like here:
Okay so I have a rough idea what I can do for the script, but I’m not sure it will work.
Like I said here, this would be the easiest way to make it.
hell naw I couldn’t join loll
Don’t make seperate scripts for each laser, you should script all of them in one script.
Oh sorry, there was a random in it, so I made it private. I’ll put it back up again
I’ll just implement/add my idea or suggestion here:
This is how I would have done it with a simple tick system.
local tickCount = 0
local tickRate = 1
-- assume buttons are stored in a table
local buttons = {Button1, Button2, Button3, Button4, Button5, Button6}
for i, button in ipairs(buttons) do
button.MouseButton1Click:Connect(function()
-- assuming the button has a bool attribute callled "isActivated"
local adjustTick = button:GetAttribute("isActivated") and 1 or -1
button:SetAttribute("isActivated", not button:GetAttribute("isActivated"))
tickRate = tickRate + adjustTick
end)
end
while task.wait(1) do
tickCount = tickCount + tickRate
if tickCount > 600 then
-- do whatever
break
end
end
If you don’t understand something, let me know.
my roblox is cursed that all of meshes and images didnt load, sorry
I don’t understand half of it, can you explain what it does?
That’s nice script, but I think it should be changed to temperature system instead of tick() because temperature system is more good on core games, and it is more easy to script
Of course! I’ll try to explain it as good as possible, excuse me if I am bad at explaining lol.
for i, button in ipairs(buttons) do
-- code
end
Here, we are simply iterating or looping through every button that controls a laser, you can add them to the “buttons” table. For example: local buttons = {workspace.LaserButton1}
button.MouseButton1Click:Connect(function()
-- code
end)
For each button we looped through, we create an event to listen to these buttons. So we can detect if someone pressed the laser button.
Now probably comes the tricky part of the code.
local adjustTick = button:GetAttribute("isActivated") and 1 or -1
We define a new variable called “adjustTick” to adjust the TickRate the Temperature is increasing. It retrieves an attribute called ‘isActivated’ on the button. It’s just like an boolValue thats either true
or false
Now in this case, I used a so called “ternary operator” which basically says if true, use “1”, else use “-1”. So if the button is activated, it should use -1 since we deactivate it now, and vice versa (the 1 and -1 in the code have to be swapped, my mistake.)
button:SetAttribute("isActivated", not button:GetAttribute("isActivated"))
Now we update the “boolValue” to whatever it was not before, basically saying if it was true, be false, and vice versa.
tickRate = tickRate + adjustTick
Here we add the new TickRate to the current TickRate, so either +1 or -1
while task.wait(1) do
tickCount = tickCount + tickRate
if tickCount > 600 then
-- do whatever
break
end
end
And here, we simply add the value of the current tickRate to the tickCount, until it eventually reaches 600.
Seconds?
Also thank you for this post, I can understand it a bit more now. Then the only question on my mind is, where do I put the script?
If no lasers are active, then yes, 600 seconds. But it will go faster when lasers will be activated due to the increasing tickRate. I would put the Script inside of ServerScriptService
.
Also, I’ll assume you will use Parts in the Workspace for the lasers buttons? For that I would use ProximityPrompts
Adjutsed code:
local tickCount = 0
local tickRate = 1
local buttons = {-- add your buttons here}
for i, button in ipairs(buttons) do
if not button:GetAttribute("isActivated") then -- This will ensure that the "boolValue" is being created.
button:SetAttribute("isActivated", false)
end
local proximityPrompt = button:FindFirstChildOfClass("ProximityPrompt")
proximityPrompt.Triggered:Connect(function()
local adjustTick = button:GetAttribute("isActivated") and -1 or 1
button:SetAttribute("isActivated", not button:GetAttribute("isActivated"))
tickRate = tickRate + adjustTick
end)
end
while task.wait(1) do
tickCount = tickCount + tickRate
if tickCount > 600 then
-- do whatever
break
end
end
Make sure to create a ProximityPrompt inside of each Button!
Let’s layout a blueprint:
A core game generally has the following:
- A core, this has a temperature value that increases and decreases overtime. Note that, usually, these games make the core have an innate passive temperature increase since the idea of a core is to produce energy with the bi-product being radiation / heat. Radiation is usually done by having the player take damage inside the room with the core if they aren’t wearing proper equipment
- Lasers or other sources of heat to speed up the heating process of the core.
- Coolant systems to cool down the core. you can ignore this since you don’t have much time
- During meltdowns, some games like to add opportunities to prevent total destruction. you can ignore this.
- Areas to protect the player from the meltdown.
Games also add other systems for more immersion but you can ignore this on release.
If you’re looking for Basic Examples of core games, I’d look at the popular ones; Pinewood and Innovation labs respectively:
If you’re looking for a more immersive approach, I’d personally suggest the QS Energy Research Facility:
This one tries to add a larger approach to the idea of managing a core by having things like power cells and other things like cargo management. I’d look at the simpler examples first but this one is good at providing that experience people usually come to the games for
With a blueprint and a few examples laid out, we can think about how to implement these systems.
Note that, I’m writing examples. they may not be applicable to you but I do believe that you should learn instead of copying code written, it’ll help add to how much you learn
The core will just need a temperature value, this can be an IntValue so its easy for other scripts to reach if more than one needs it.
An Intvalue is a game object that stores an Interger value (numbers) in which the value can be reached by using IntValue.Value
There should be a script that checks if it is on, if it’s always on then ignore this. it may go along the lines of the following:
-- Activating the core
local IsActive = false
local button = workspace.ActivationButton -- reference the button that activates the core
button.ClickDetector.Activated:Connect(function(plr)
if IsActive == false then
IsActive = true
print(plr.."Has activated the core")
-- Add anything you want to happen here,
else
print(plr.."has turned off the Core.")
IsActive = false
end
end)
now that the core is on, we’ll need to have its temperature begin to rise passively. We can do this by sending a BindableEvent to another script that manages the core. A Bindable Event is something that allows you to get data from one script, and fire it to another. Note that Bindable Events are for Server to Server communication and if you’re transferring data from a client to a server, you will want to use Remote Events instead.
Bindable Events are their own object that you’ll have to insert and reference. Here is an example of a Bindable Event in action:
SCRIPT 1
BE = workspace.BindableEvent
Numbers = {
1,
2,
3,
4,
5
}
ChosenNumber = math.random(1, #Numbers) -- gets a random number from 1 to the amount of numbers in the table
BE:Fire(ChosenNumber) -- Fires the event for the other script to catch. we're sending the Random Number variable which contains the randomised number
SCRIPT 2
BE = workspace.BindableEvent
BE.Event:Connect(Num) -- "Num" is "RandomNumber"
print("The Number recieved is: "..Num) -- prints the random number from script 1.
With this, you can infer how these events work and implement them in whatever way you intend.
With this, we can tell the core script that it’s now activated, and to begin heating. We can do this by having a loop that increases the temperature every set amount of time:
Temp = workspace.IntValue
Limit = 5000 -- temperature limit
Rate = 1.3 -- passive heat increase rate
Multiplier = 0 -- We will have lasers add to this value
BE.Event:Connect(function(IsOn)
if IsOn == true then
while True do -- Loops forever until the "until" condition is met
Temp.Value = Temp.Value + Rate -- Adds the rate to the current value
if IsOn == false then
break -- if the core is turned off, the loop is broken.
else
end
until Temp >= Limit -- Stops once the core reaches the stated limit
end
end)
Lasers can add more to the temperature increase, Or multiply it. As ESP said:
We can manage all lasers in a single script. You can use Tables to store them together. Tables act as a way to store multiple data or variables and whatnot in a single variable. I had used an example above.
We can even store tables in tables. as shown below.
BE2 = workspace.BindableEvent2
local Lasers = {
Laser1 = {Object = workspace.Laser1, Button = workspace.Laser1Button, IsActive = false},
Laser2 = {Object = workspace.Laser2, Button = workspace.Laser2Button, IsActive = false},
Laser3 = {Object = workspace.Laser3, Button = workspace.Laser3Button, IsActive = false},
Laser4 = {Object = workspace.Laser4, Button = workspace.Laser4Button, IsActive = false},
}
--[[What we have done above is assign the location of the laser, its button and its state in a table. the rest of the script can refer to all 3 values at any time.]]--
ActiveCount = 0 -- will add / take away from depending on the amount of active lasers
for i, v in pairs(Lasers) do -- goes through the table. "V" is the variable set butt can differ, I suggest looking at the documentation for more info.
if v["Button"] then
v.Button.Activated:Connect(function()
if v.IsActive == false then
v.IsActive = true
ActiveCount = ActiveCount + 1
BE2:Fire(ActiveCount)
else
v.IsActive = false
ActiveCount = ActiveCount - 1
BE2:Fire(ActiveCount)
end
end)
end
end
Now the script manages whether lasers are on or not. We can infer this back to the temperature script:
BE = workspace.BindableEvent
BE2 = workspace.BindableEvent2 -- You can use the same bindable event for sending different data, I just split them to make it more simple to understand.
Temp = workspace.IntValue
Limit = 5000 -- temperature limit
Rate = 1.3 -- passive heat increase rate
Multiplier = 0 -- We will have lasers add to this value
BE2.Event:Connect(function(Count)
Multiplier = Count * 0.25
end)
BE.Event:Connect(function(IsOn)
if IsOn == true then
while True do -- Loops forever until the "until" condition is met
Temp.Value = Temp.Value + Rate * Multiplier -- Adds the rate to the current value and multiplies it depending on lasers active.
if IsOn == false then
break -- if the core is turned off, the loop is broken.
else
end
until Temp >= Limit -- Stops once the core reaches the stated limit
end
end)
Now that the lasers work, this basically covers the essentials. Coolants can work in their own ways but this is really all you need to do.
Again, This is not code that you should just copy paste, as it was not written with that intent nor would I do so. This is something you can infer from as a reference of what to do or a basic example of how cores work. I have linked multiple documentations around and you should refer to those as they cover some extremely useful tools that you can use.
With this, should I put the script in the serverscriptservice?
Where does this go?
Where does this go?
And where does this go?
It was not written to support your structure, I stated this at the end. these scripts are for you to understand how some things may work and examples of how they would operate. As I said, you’ve only got 6 days so trying to revamp the system in that time can be quite the risk considering it was delayed twice before. I would only try to tackle a system revamp when you’re free to do so in your own time that isn’t under a nearby deadline. I suggest reading what I have said before looking at the code.
Instead of asking where scripts should go, I suggest looking at the main places that scripts do go and looking at why scripts are placed there. here are a few examples:
You have three types of scripts in ROBLOX:
- Local Scripts, these refer to the specific client. A client is basically the player.
- Server scripts, these operate on the server.
- Module Scripts, these act as places to reference functions / data that multiple other scripts may use.
The placement of scripts matter more on what that script is using. Local scripts can’t access certain things but are able to use things such as UserInputService which server scripts wouldn’t be able to.
There’s a greater amount of detail in their difference which you can find on the documentation of whatever you use
I would probably be placing these scripts in their relevant objects. I would assume all of the scripts used are server sided since there’s no reason for them to be local or contain a module (though modules will come in handy when you complicate the system overtime.) Scripts that should be loading in first can go in ReplicatedFirst. There’s also ServerScriptService. I’m unsure of what this is specifically for but I place scripts that manage large systems here. and again, to be clear, You shouldn’t be using these anyway as they were not made with the intent of being used nor written in a way that would support its use properly. They are examples.
Thank you so much for your encouraging words! All I have to say now is there is another error, how can I fix this?
you’re missing an end, as the error says
Where though? I don’t see where I’m missing one
there shouldn’t be an until statement. the error says that it expects end to close the while true do statement.
BE.Event:Connect(function(IsOn)
if IsOn == true then
while temp.Value < Limit do -- Loops forever until the "until" condition is met
Temp.Value = Temp.Value + Rate -- Adds the rate to the current value
if IsOn == false then
break -- if the core is turned off, the loop is broken.
else
end
end
end
end)