Tunnells
(PlaySage)
April 11, 2021, 12:08pm
1
So i want to get a random number every day and night and if the random number == 1 for example it would play a event
while true do wait()
local BloodHourChance = math.random(1,1)
print(BloodHourChance)
game.Workspace.The_Rake.Parent = game.ServerStorage
game.Workspace.Ambient:Stop()
game.Lighting.FogEnd = 190
game.Workspace.DayTimeSong:Play()
Morning:Play()
wait(5)
game.ReplicatedStorage.CheckPlayer:FireAllClients()
FogMorning:Play()
wait(210)
game.Workspace.NightTime:Play()
Night:Play()
wait(5)
game.Workspace.Ambient:Play()
FogTween:Play()
game.Lighting.FogEnd = 50
wait(5)
game.ReplicatedStorage.Night:FireAllClients()
game.Lighting.Brightness = 1
game.ServerScriptService.Fix.Disabled = false
game.Workspace.Vibrate.Disabled = false
wait(5)
game.Workspace.Vibrate.Disabled = true
game.ServerScriptService.Fix.Disabled = true
game.ServerStorage.The_Rake.Parent = game.Workspace
game.Workspace.RakeScream:Play()
if StunstickValue.Value == 10 or BloodHourChance == 1 then
print("BloodHour has started Poggers")
else
wait(140)
end
end
``` I removed the post by mistake LOL
You have made it so it will always equal 1, change this to math.random(0,1), if you want a 50% chance
Tunnells
(PlaySage)
April 11, 2021, 12:12pm
3
I put it at 1,1 so i can check if it would work i also want the stun stick value to be 10 to start also
Do you have a day and night system, in place?
Tunnells
(PlaySage)
April 11, 2021, 12:16pm
5
the day and night script is the script above
the full script
local lighting = game:GetService("Lighting")
local ts = game:GetService("TweenService")
local transition = 15
local ti = TweenInfo.new(transition,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)
local Morning = ts:Create(lighting,ti,{ClockTime = 14})
local Night = ts:Create(lighting,ti,{ClockTime = 0})
local TweenS = game:GetService("TweenService")
local Lighting = game.Lighting
local BloodHourChance = math.random(1,5)
local TweenInf = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local StunstickValue = game.Workspace.The_Rake.Stun.GetStuns
local Finish = {FogColor=Color3.new(0.611765, 0.572549, 0.490196)}
local Nights = {FogColor=Color3.new(0, 0, 0)}
local FogTween = TweenS:Create(Lighting, TweenInf, Nights)
local FogMorning = TweenS:Create(Lighting, TweenInf, Finish)
while true do wait()
local BloodHourChance = math.random(1,1)
print(BloodHourChance)
game.Workspace.The_Rake.Parent = game.ServerStorage
game.Workspace.Ambient:Stop()
game.Lighting.FogEnd = 190
game.Workspace.DayTimeSong:Play()
Morning:Play()
wait(5)
game.ReplicatedStorage.CheckPlayer:FireAllClients()
FogMorning:Play()
wait(210)
game.Workspace.NightTime:Play()
Night:Play()
wait(5)
game.Workspace.Ambient:Play()
FogTween:Play()
game.Lighting.FogEnd = 50
wait(5)
game.ReplicatedStorage.Night:FireAllClients()
game.Lighting.Brightness = 1
game.ServerScriptService.Fix.Disabled = false
game.Workspace.Vibrate.Disabled = false
wait(5)
game.Workspace.Vibrate.Disabled = true
game.ServerScriptService.Fix.Disabled = true
game.ServerStorage.The_Rake.Parent = game.Workspace
game.Workspace.RakeScream:Play()
if StunstickValue.Value == 10 or BloodHourChance == 1 then
print("BloodHour has started Poggers")
else
wait(140)
end
end
Is it printing anything? Sorry for the late reply, i was testing something,
or how is the script acting?
Tunnells
(PlaySage)
April 11, 2021, 12:23pm
7
It prints when not supposed to cause stun stick is still 0
Tunnells
(PlaySage)
April 11, 2021, 12:23pm
8
then it turns morning without waiting 140 seconds
You used the or argument from what you are claiming this should be and
Tunnells
(PlaySage)
April 11, 2021, 12:26pm
10
let me test if i put and cause i rememeber i made a post with and, and it didnt work
The “or” argument would cause this argument your asking if either one of the bounds set is true in this case. Which is not what you want, from what you said you want both bounds to be true which is why you would need to use “and”
Tunnells
(PlaySage)
April 11, 2021, 12:32pm
12
Would this code keep checking?
if StunstickValue.Value == 10 and BloodHourChance == 1 then
print("Pog")
end
yes it would if both values don’t equal their requirements
once both values equal their requirements it would print “Pog”
Tunnells
(PlaySage)
April 11, 2021, 12:36pm
14
It doesnt print
local BloodHourChance = math.random(1,1)
local StunstickValue = game.Workspace.The_Rake.Stun.GetStuns
local BloodHourChance = math.random(1,1)
local StunstickValue = game.Workspace.The_Rake.Stun.GetStuns
if BloodHourChance == 1 and StunstickValue.Value == 10 then
print(BloodHourChance)
print("Pog")
end
```
I tested it should work… Try this
if (BloodHourChance == 1 and StunstickValue.Value == 10) then
Tunnells
(PlaySage)
April 11, 2021, 12:44pm
16
nOPE
local BloodHourChance = math.random(1,1)
local StunstickValue = game.Workspace.The_Rake.Stun.GetStuns
print(BloodHourChance)
if (BloodHourChance == 1 and StunstickValue.Value == 10) then
print(BloodHourChance)
print("Pog")
end
```
Try this wanna slim down the problem
Put this in a new script
local BloodHourChance = math.random(1,1)
local StunstickValue = 10
print(BloodHourChance)
if (BloodHourChance == 1 and StunstickValue == 10) then
print(BloodHourChance)
print("Pog")
end
Tunnells
(PlaySage)
April 11, 2021, 12:48pm
18
Well this works, BUT, i want it basically if a player hits a npc it increase the stun stick by +1 would this code work?
No, no I know I wanted you to do this so I can know where the problem is and it lies where you handle StunstickValue, can you post the new script you had for handling day/night system?
Tunnells
(PlaySage)
April 11, 2021, 12:50pm
20
local BloodHourChance = math.random(1,1)
local StunstickValue = game.Workspace.The_Rake.Stun.GetStuns.Value
print(BloodHourChance)
if (BloodHourChance == 1 and StunstickValue == 10) then
print(BloodHourChance)
print("Pog")
end
``` ye