How to make a Power Mechanic like in FNaF 1

  1. What do you want to achieve?
    I want to make a FNaF game on roblox, as I am into the game a lot, and I want to make a game too, like Five Nights at Maylee’s, and there are no tutorials on how to do a Power Mechanic. (I am still a beginner, but any tutorials on youtube videos
    that you send and I find it working, I’m going to be very helpful)

  2. What is the issue?
    I inserted a script inside text label which is in a ScreenGui which is inside of the StarterGui. I want the power go down by 1% every 5 seconds, so I want to text to wait 5 seconds and then show 99 power, then wait another 5 seconds, and the power will got down to 98, but for me, the text isn’t showing up, here’s my script:
    script.Parent.Text(function()

wait(5)

script.Parent.Text = “99”

wait(5)

script.Parent.Text = “98”

end)

Now, I also want to power go down when the door, cameras or lights are closed/up, so I want only being still, the power will go down by 1x, one door/light or camera, the power will be going down by speed 1.2x, two doors/two lights, or camera and a door, will be 1.2x and so on, I didn’t know to make this, but I don’t know any tutorials to start my first game, but here is my script:

db = false
door = false
script.Parent.LightButton.ClickDetector.MouseClick:connect(function()
** script.Parent.LightButton.Sound:play()**
** if script.Parent.Light.PointLight.Brightness == 1 then**
** script.Parent.Light.PointLight.Brightness = 0**
** script.Parent.Light.Sound.Volume = 0**
** elseif script.Parent.Light.PointLight.Brightness == 0 then**
** script.Parent.Light.PointLight.Brightness = 1**
** script.Parent.Light.Sound.Volume = 1**
** end**
end)

script.Parent.DoorButton.ClickDetector.MouseClick:connect(function()
** if not db then db = true**
** if not door then door = true**
** script.Parent.Door.Sound:play()**
** for i=0,15 do**
** script.Parent.Door.CFrame = script.Parent.Door.CFrame - Vector3.new(0,0.8,0)**
** wait()**
** end**
** script.Parent.Door.CFrame = script.Parent.Door.CFrame - Vector3.new(0,0.2,0)**
** db = false**
** elseif door then door = false**
** script.Parent.Door.Sound:play()**
** for i=0,15 do**
** script.Parent.Door.CFrame = script.Parent.Door.CFrame + Vector3.new(0,0.8,0)**
** wait()**
** end**
** script.Parent.Door.CFrame = script.Parent.Door.CFrame + Vector3.new(0,0.2,0)**
** db = false**
** wait()**
power = power - 1
** end**
** end**
end)

  1. What solutions have you tried so far?
    Looking on DevForums, didn’t see any. Looking on youtube, no tutorials/how to make it. Even tried changing the scripts a little, didn’t work(if anyone has any tutorials I would be really helpful)
2 Likes

Uhh what is a “Power Mechanic” exactly?

1 Like

I call a Power Mechanic in FNaF is that your power always decreases, but if you close more doors/opens cameras, the power decreases faster, when the power goes to 0%, you can’t close doors and you have to pray for animatronics not jumpscare you.

1 Like

Make a seperate power script inside the player. Decrease the player’s power consistently.with a Heartbeat function. Your script would look something like this:

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)
5 Likes

Hello, the script isn’t working, how to make it work with the “objectsActivated” thing?

1 Like