local Sick = script.Parent
while true do
task.wait(60)
local chance = math.random(0,100)
if chance <= 40 then Sick = true
elseif chance >= 41 then return end
end
unfortunately this doesn’t seem to work? it’s meant to randomly change a boolvalue named “Sick”, the sick value is in startergui, with the script being inside of it
I made this script that should work just copy paste and tell me.
local sick = script.Parent
while task.wait(60) do
local rng = math.random(1, 100)
if rng <= 40 then
sick.Value = true
print("Success", rng)
else
sick.Value = false
print("Failed", rng)
end
end
Make this a script inside the value. (Not a local script).
local Sick = script.Parent
while true do
task.wait(60)
local chance = math.random(0,100)
print(chance) -- you can check here where was chance was created
if chance <= 40 then
Sick.Value = true -- every boolvalue always need Value=True or Value=false
elseif chance >= 41 then
return -- "return" it mean loop it's already stopped here similiar "break"
end
end
local Sick = game.Players.LocalPlayer.PlayerGui:WaitForChild("Sick")
while true do
task.wait(60)
print("Does it still work here?")
local chance = math.random(0,100)
if chance <= 40 then Sick.Value = true
print ("You got infected")
elseif chance >= 41 then return end
print("Not sick!")
end
tried this as a script in serverscriptservice, but didnt work, it didnt seem to print anything either
Try using my script inside your value just a normal script not a local.
local sick = script.Parent
while task.wait(60) do
local rng = math.random(1, 100)
if rng <= 40 then
sick.Value = true
print("Success", rng)
else
sick.Value = false
print("Failed", rng)
end
end
I dont think soo. i can show 1 example that script work in ServerScriptService
task.wait(1) -- just let load first
local Sick = game.Players:FindFirstChildOfClass('Player').PlayerGui:WaitForChild("Sick")
while true do
task.wait(2) -- Previous was 60 sec
print("Does it still work here?")
local chance = math.random(0,100)
print(chance)
if chance <= 40 then Sick.Value = true
print ("You got infected")
return
elseif chance >= 41 then
print("Not sick!")
return
end
end