So basically I want the player's walk speed to change whenever it is in the Terrain water. What I made bellow works, but I'd like it to be more efficient, and only change when the player is in/out of the water. I don't really know how to go about doing so, and I would really appreciate some help <3
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
local drown = false
humanoid.Swimming:connect(function(swim)
if swim > 0 then drown = true
elseif swim < 1 then drown = false
end
end)
while wait(0.1) do
if drown then humanoid.WalkSpeed = 5
else
local found = game.Workspace:FindFirstChild(humanoid.Parent.Name.."'s_folder")
if found then
humanoid.WalkSpeed = found.Speed.Value
end
end
end
end)
end)
****
Happy murica day!
