So i want to make a blood hour on my game , its a event that is random if a npc gets hit to much.
The chances off it happening is 1,3 chance and every night it gets a random number how would i do it?
You can do something like this:
local npc = workspace.NPC
local npcHum = npc.Humanoid
local lastHP = npcHum.Health
local trigger = 25 -- 25HP damage needs to be done to trigger
npcHum:GetPropertyChangedSignal("Health"):Connect(function()
if lastHP - npcHum >= trigger then
local randNum = math.random(1,3)
if randNum == 1 or randNum == 2 then
--Do BloodHour stuff
end
end
end)
Sorry for the bad formatting as I cannot access studio rn
Well i mean like it would mix in a day and night cycle and every night it would get a new random number
How would i tie that code in with this
-- Variables
local Lighting = game:WaitForChild("Lighting")
local Tween = game:GetService("TweenService")
-- Locals
local NightTime = Tween:Create(Lighting, TweenInfo.new(10), {ClockTime = 0}) -- Gives the Tween for it to turn night
local NightFog = Tween:Create(Lighting, TweenInfo.new(10), {FogColor = Color3.fromRGB(0, 0, 0)})
local DayTime = Tween:Create(Lighting, TweenInfo.new(15), {ClockTime = 14})
local DayFog = Tween:Create(Lighting, TweenInfo.new(15), {FogColor = Color3.fromRGB(159, 151, 127)})
while true do
wait(15)
NightTime:Play()
NightFog:Play()
wait(11)
DayTime:Play()
DayFog:Play()
end
well i dont want it too print the time i mean like
when it turns night it picks a number from 1 to 3
every cycle
A bunch of values, that is what I used for my Rake game
hmmm that code seems oddly familiar… anyways, first you should create another tween for the blood hour (2 of them) then for the health, you could go off of what @TheBrainy06 said and detect if the rake’s health is less than a certain number using GetPropertyChangedSignal("Health")
then a if
statement; if Rake.Humanoid.Health <= 30 then
use the tweens for blood hour, now for the random chance of it, you could use math.random (1,3)
for everytime Rake’s health gets to less than 30.
Ya that would be a way better option