The swim script doesn’t work, even though it should?
(It is a local script that sits in StarterPlayerCharacters)
game:GetService("RunService").Heartbeat:Connect(function()
local swimrn = true
print("Beginning swim test")
if val.Value == true then
db.Value = config.touchendticks
local swimrn = true
print("Can swim. Reset DB.")
else
db.Value -= 1
print("Removed one DB. ".. tostring(db.Value))
end
if db.Value < 1 then
swimrn = false
end
print("Swimming begin if is true: ".. tostring(swimrn))
if swimrn == true then
print("Swimming begun")
Humanoid:SetStateEnabled("GettingUp", false)
if currentswim == false or Instance.new("Humanoid"):GetState() ~= Enum.HumanoidStateType.Swimming then
Humanoid:ChangeState("Swimming")
end
currentswim = true
breathh.Value -= 1
if breathh.Value < 1 then
Humanoid.Health = 0
end
else
print("Swimming ended")
currentswim = false
Humanoid:SetStateEnabled("GettingUp", true)
breathh.Value = config.breath
end
print("Ending swim test")
end)
Edit: There are no erros and the script doesn’t yield, it’s a issue with the character going in and out of swimming state