Run on water like the flash?

Hello, I used to have a system that allowed me to run on water if I was going fast.

Sadly, I do not have that system anymore because it was not mine, it was old.
How do I detect if the player is on Water?

And if you’re on water and, you’re going fast you can run on top of the water instead of falling inside.

Any help Is greatly appreciated

(I already know how to put the player on top of the water (I think), I just need to know how they’re in water or touched water.

Just check whenever player’s speed is above 16 or whatever the default speed is then set the waters CanCollide to true.

Ig that’ll do it right?

2 Likes

Terrian Type water, I already know about the speed.

To add on, you could add a transparent block in the water if speed is < 16, CanCollide = false and vice versa.

3 Likes

Not a bad idea, I’ll see what I can do.

Works fine, Simple! Thanks.

This text will be blurred

1 Like
local Enumeration = Enum
local Game = game
local Workspace = workspace
local Players = Game:GetService("Players")
local RunService = Game:GetService("RunService")

local function OnHeartbeat()
	for _, Player in ipairs(Players:GetPlayers()) do
		local Character = Player.Character
		if not Character then continue end
		local Head = Character:FindFirstChild("Head")
		if not Head then continue end
		local Size = Character:GetExtentsSize()
		
		local Parameters = RaycastParams.new()
		Parameters.FilterDescendantsInstances = {Character}
		local Result = Workspace:Raycast(Head.Position, Head.CFrame.UpVector * -Size.Y, Parameters)
		if not Result then continue end
		if Result.Instance.Name ~= "Terrain" then continue end
		if Result.Material ~= Enumeration.Material.Water then continue end
		--Do something if terrain material is water.
	end
end

RunService.Heartbeat:Connect(OnHeartbeat)
1 Like

Yes yes yes yes, thank you so much.