This is the log over 8.5 seconds: 21:32:32.155 - Baseplate was auto-saved (x2) swimming (x17)
local p = game.Players.LocalPlayer
local c = p.Character
local m = p:GetMouse()
local sprint = false
local t,f = true,false
local w,a,s,d = f,f,f,f
local wt = 0
function lower() -- player starts drowning if they are swimming
c.Humanoid.Health = c.Humanoid.Health -1
end
m.KeyDown:connect(function(key)
if key == '0' then
sprint = t
end
if key == 'w' then
w = t
end
if key == 'a' then
a = t
end
if key == 's' then
s = t
end
if key == 'd' then
d = t
end
end)
m.KeyUp:connect(function(key)
if key == '0' then
sprint = f
end
if key == 'w' then
w = f
end
if key == 'a' then
a = f
end
if key == 's' then
s = f
end
if key == 'd' then
d = f
end
end)
while wait() do
wt = wt - .01
if wt <= 0 then
if script.Parent.Frame.Bar.Size.X.Scale < .9 then
script.Parent.Frame.Bar.Size = script.Parent.Frame.Bar.Size + UDim2.new(.009,0,0,0)
end
end
if w or a or s or d then
if script.Parent.Frame.Bar.Size.X.Scale > 0 and sprint then
script.Parent.Frame.Bar.Size = script.Parent.Frame.Bar.Size - UDim2.new(.009,0,0,0)
c.Humanoid.WalkSpeed = 20
end
end
if sprint then
wt = 1.3
end
if not w and not a and not s and not d then c.Humanoid.WalkSpeed = 12 end
if not sprint then c.Humanoid.WalkSpeed = 12 end
if script.Parent.Frame.Bar.Size.X.Scale <= 0 then c.Humanoid.WalkSpeed = 12 end
if c.Humanoid.Swimming:connect(lower) then print("swimming") wait(0.5)end -- detects if a player is swimming
end
