Sorry, I had no idea how to phrase that with only 1 sentence but I will try my best to explain here. In the game I am creating I have GUI's set up that show the needs of a player. For example hunger which is scripted like this:
local Hunger = script.Parent.Parent.Parent.Hunger
local p = script.Parent
local char = Hunger.Parent.Parent.Parent.Character
while wait(14) do
if Hunger.Value < 100 then
Hunger.Value = Hunger.Value + 1
p.Size = UDim2.new(-(Hunger.Value/100),0,2,0)
else
if char ~= nil then
if char:FindFirstChild("Humanoid") then
char.Humanoid:TakeDamage(500)
end
end
end
end
This kills the player when hunger reaches 100 (Meaning your very hungry/starving)
However I have a sleep need that does the same thing, but unlike hunger it sets your walkspeed to 1. The script is as follows (I was too lazy to change variables so it still says hunger but you get the point)
local Hunger = script.Parent.Parent.Parent.Hunger
local p = script.Parent
local char = Hunger.Parent.Parent.Parent.Character
while wait(14) do
if Hunger.Value < 100 then
char.Humanoid.WalkSpeed = 16
Hunger.Value = Hunger.Value + 1
p.Size = UDim2.new(-(Hunger.Value/100),0,2,0)
else
if char ~= nil then
if char:FindFirstChild("Humanoid") then
char.Humanoid.WalkSpeed = 1
end
end
end
end
This is where it gets bad. I have other "needs" that do the same thing, they set your walkspeed to a slower speed. Since the script is on a wait() for all of them.. what happens is once your sleep gets to 100 (sleep deprived) your walkspeed is set to 1 every 14 seconds, but if another script tests as good (example bladder is not at 100 yet so you are not in need of a toilet lol) then the script says wait(x) seconds and that script will reset your walkspeed to 16.
I need a workaround for this. A way for the script to test that if at least one of these is at 100, then do not reset the walkspeed to 16, leave it at what it is. Hopefully that's not too confusing. Thanks for the help.
Edit: Possible solution, if I add a local script to starterGUI and test for if at least one of the "needs" are at 100 then put the walkspeed to say 5... then it would work. However, I don't know how to do this as all of the "needs" are seperate gui. I am thinking something like this...
local char = script.Parent.Parent.Character
while wait(1) do
if script.Parent.Bladder.Hunger.Value == 100
or script.Parent.SleepNeed.Hunger.Value == 100
or script.Parent.Fun.Hunger.Value == 100
or script.Parent.Hygene.Hunger.Value == 100
or script.Parent.Social.Hunger.Value == 100 then
char.Humanoid.WalkSpeed = 5
print("True")
else
print("False")
end
endhar.Humanoid.WalkSpeed = 5
end
I don't know how to do OR, is that even correctly stated? I'm sure you get what I am trying to do. This is not working however... Even print isn't working.
Solution: A local script that checks all of them...
local char = script.Parent.Parent.Character
while true do
wait(1)
if script.Parent.Bladder.Hunger.Value == 100
or script.Parent.SleepNeed.Hunger.Value == 100
or script.Parent.Fun.Hunger.Value == 100
or script.Parent.Hygene.Hunger.Value == 100
or script.Parent.Social.Hunger.Value == 100 then
print("Walkspeed = 5")
char.Humanoid.WalkSpeed = 5
else
char.Humanoid.WalkSpeed = 16
print("Walkspeed = 16")
end
end
Side note: I don't know how to select an answer and mark it as correct on this website so please explain that briefly in your response if you think you know a work around to this. :)

1 comment
Posting to help anyone who might have some sort of similar issue, answer is also in original post :)