Swimable Water In Voxel Sandbox Help needed

I am making a Minecraft terrain
But I’m using voxels I don’t know how can make I make the Player swim

En.Swim.Event:Connect(function(X,Y,Z,Char)
	local humanoid = Char.Humanoid
	
	if Engine.IsFluid(X,Y,Z) then
		-- Enable swim
	else
		-- Disable swim
	end
end)

This script has to be done on client. You can’t make player swim on server.

local Swim = nil

En.Swim.Event:Connect(function(X,Y,Z,Char)
	local humanoid = Char.Humanoid
        local Root = Char.HumanoidRootPart
	
	if Engine.IsFluid(X,Y,Z) then
		Swim = Instance.new("BodyVelocity")
			Swim.Parent = Root
	Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
			Humanoid:ChangeState(Enum.HumanoidStateType.Swimming)
	else
		Swim:Destroy()
		Swim = nil
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
	end
end)

game:GetService("RunService").RenderStepped:Connect(Function()
if not Swim then
return
end
		Swim.Velocity = Humanoid.MoveDirection * Humanoid.WalkSpeed
end)

maybe this helps

1 Like

I already found how to do it
:smiley:

1 Like