local player = game:GetService("Players").LocalPlayer
player.CharacterAdded:Wait()
local char = player.Character
local module = require(script.Parent.Parent.oxygen)
local maxOxygen = module.maxOxygen
local oxygen = module.oxygen
while true do
task.wait()
oxygen -= 1
script.Parent.Text = (oxygen .. "%")
print(oxygen)
if oxygen < 1 then
player:Kick()
break
end
end
It won’t run for some reason.(the while true won’t)
If the module script is inside ServerScriptService, you won’t be able to require it from a LocalScript, so you’ll have to move the module script to ReplicatedStorage.
If that isn’t the issue, then look in the output for any errors and place some print statements in your code to detect when it stops running.
local RS = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
player.CharacterAdded:Wait()
local char = game.Workspace:WaitForChild(player.Name) or player.Character or player.CharacterAdded:Wait()
local module = require(RS.oxygen)
local maxOxygen = module.maxOxygen
local oxygen = module.oxygen
while true do
task.wait()
oxygen -= 1
script.Parent.Text = (oxygen .. "%")
print(oxygen)
if oxygen < 1 then
player:Kick()
break
end
end