Why isnt my Velocity Script working?

local RS = game:GetService("RunService")
local CHARACTER = game.Players.LocalPlayer.CharacterAdded:Wait()

local VELOCITY_DAMAGE_SPEED = 0.01

RS.RenderStepped:Connect(function()
	if CHARACTER:WaitForChild("HumanoidRootPart").Velocity.X > VELOCITY_DAMAGE_SPEED or CHARACTER:WaitForChild("HumanoidRootPart").Velocity.Y > VELOCITY_DAMAGE_SPEED or CHARACTER:WaitForChild("HumanoidRootPart").Velocity.Z > VELOCITY_DAMAGE_SPEED then
		print("DIE")
		game.ReplicatedStorage.Events.Ragdoll:FireServer(true)
		wait(2)
		game.ReplicatedStorage.Events.Ragdoll:FireServer(false)
	end
end)

The script never prints DIE at all. Even when my Humanoid’s Root part velocity is higher than 0.01, What am I doing wrong?

2 Likes

I wouldn’t exactly set a Character variable to only detect for a Character to be added via an Event

local RS = game:GetService("RunService")
local Player = game.Players.LocalPlayer

local CHARACTER = Player.Character or Player.CharacterAdded:Wait()
local VELOCITY_DAMAGE_SPEED = 0.01

RS.RenderStepped:Connect(function()
	if CHARACTER:WaitForChild("HumanoidRootPart").Velocity.X > VELOCITY_DAMAGE_SPEED or CHARACTER:WaitForChild("HumanoidRootPart").Velocity.Y > VELOCITY_DAMAGE_SPEED or CHARACTER:WaitForChild("HumanoidRootPart").Velocity.Z > VELOCITY_DAMAGE_SPEED then
		print("DIE")
		game.ReplicatedStorage.Events.Ragdoll:FireServer(true)
		wait(2)
		game.ReplicatedStorage.Events.Ragdoll:FireServer(false)
    else
        print("No")
	end
end)
1 Like

Hi, I just tested your script by putting it in a LocalScript in StarterPlayer > StarterPlayerScripts. I would double check where you put this script in your game as that might be the issue. I hope this helps!