I made a server script and place it into ServerScriptService. The script is suppose to decrease their thirst and when I tested it I received no errors from the script and the script doesn't work at all. Can someone help me out here please? If you can then thank you!
Script:
print("Loading Thirst..") wait(1) print("Thirst successfully loaded!") --//Services local Players = game:GetService("Players") --//Function Players.PlayerAdded:Connect(function(Player) --//Variables local MaxThirst = Player.Stats:WaitForChild("MaxThirst") local Thirst = Player.Stats:WaitForChild("Thirst") local Humanoid = Player.Character:WaitForChild("Humanoid") local DecreaseRate = 1 local SubtractThirst = 2 local SubractHealth = 100 --//Main while wait(DecreaseRate) do if Thirst.Value - 1 >= 0 then Thirst.Value = Thirst.Value - SubtractThirst end if Thirst.Value == 0 then repeat wait(2.5) Humanoid.Health = Humanoid.Health - SubractHealth until Thirst.Value > 0 or Humanoid.Health <= 0 end if Humanoid.Health == 0 then Player.Stats.MaxThirst:Destroy() Player.Stats.Thirst:Destroy() end end end)
Not entirely sure if this is the issue, but I think it's because you put:
if Thirst.Value == 0 then repeat wait(2.5) Humanoid.Health = Humanoid.Health - SubractHealth until Thirst.Value > 0 or Humanoid.Health <= 0 end
I don't know too much about the whole repeat thing, but this is my best guess as to what's wrong. Instead of using repeat wait(2.5) or whatever, try this:
if Thirst.Value == 0 then while wait(2.5) do if humanoid.Health == 0 then break end humanoid.Health = humanoid.Health - SubtrackHealth end end
Not sure if I did much for you, but this is the best I got, I hope it works!