below is a script with zero errors:
01 | players = game.Players:GetPlayers() |
02 | while true do |
03 | wait( 1 ) |
04 | print ( "test" ) |
05 | for i,v in pairs (players) do |
06 | print ( "test2" ) |
07 | local character = v.Character or v.CharacterAdded:Wait() |
08 | repeat |
09 | wait() |
10 | until character |
11 | local humanoid = character:WaitForChild( "Humanoid" ) |
12 | if character:FindFirstChild( "thirst" ).Value < = 20 then |
13 | humanoid.Health = humanoid.Health - 40 |
14 | end |
15 | if character:FindFirstChild( "hunger" ).Value < = 20 then |
no errors? then what is the problem? you may ask, I have no clue... where does it stop? it stops at the part where it says:
1 | for i,v in pairs (players) do |
it prints "test" but not "test2"
EDIT: i found out to fix it i had to put :getplayers into the while loop and make it local
Try:
01 | local Players = game:GetService( "Players" ) |
02 |
03 | local function ThirstHunger(Player) |
04 | while true do |
05 | print ( "Test2" ) |
06 | local Character = Player.Character or Player.CharacterAdded:Wait() |
07 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
08 | if Character.thirst.Value < = 20 then |
09 | Humanoid.Health = Humanoid.Health - 40 |
10 | end |
11 | if Character.hunger.Value < = 20 then |
12 | Humanoid.WalkSpeed = 5 |
13 | else |
14 | Humanoid.WalkSpeed = 12 |
15 | end |