What does this script mean?

  1. What do you want to achieve?
    I want to understand this script.

  2. What is the issue?
    I don’t understand this script:

RunService = game:GetService(“RunService”)

local t = 0
RunService.Heartbeat:Connect(function(step)
t += step
if t >= rateOfPowerDecreasing then
power -= 1 + (objectsActivated*0.2)
t = 0
end
end)

  1. What solutions have you tried so far?
    Now, as this is a script, it isn’t really searchable.

What part of the script don’t you understand? and what part of it do you want to understand? You need to be more specific about your problem. (Also use the ``` formatting for scripts)

I don’t know how to make the objectsActivated count higher, when the door/light is on. (when I press a button)

RunService.Heartbeat fires every heartbeat, so the function will run every 1/30th of a second, roughly.

1 Like

Could you give us a bit more information on what you want to achieve? “Understanding the script” is a bit vague.

I don’t understand how to make the objectsActivated variable go up, when you click a button.

What do you mean by variable? Is objectsActivated an IntValue that is set to a variable? I still don’t understand what you mean by making the objectsActivated variable “go up”

By go up I meant if you click a button, it jumps from 1, to 2.

I get the feeling this isn’t your script, nor do you have any experience scripting at all. I’d recommend learning to script.
https://education.roblox.com/en-us/resources/intro-to-coding

1 Like

You would need an IntValue and a ClickDetector. For example…

local cd = script.Parent.ClickDetector
local objectsActivated = script.Parent.IntValue
cd.MouseClick:Connect(function()
    objectsActivated.Value = objectsActivated.Value + 1
    print(objectsActivated.Value.." Object(s) have been activated")
end)

This is also how you would want to place the items into workspace:
image

1 Like

I can’t help you with scripts, but you can look it up on youtube, there will be a youtuber who teached the exact same thing.

1 Like

Do you know the youtuber’s name?


AlvinBlox

1 Like

Thanks a lot for helping! :smiley:

Thanks, I actually started learning some stuff with PeasFactory, but I wasn’t that far into learning scripting!

Always, take care bro. :relieved:

1 Like