How do I make this work?

Hi, I am trying to make this so when the player touches another players head, and the raycast detects it, it makes the player slip backwards:

My code:

local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")

local Player = Players.LocalPlayer



RunService.RenderStepped:Connect(function()

	local Character = Player.Character or Player.CharacterAdded:Wait()

	if Character and Character:FindFirstChild("HumanoidRootPart") then
		local original = Character.HumanoidRootPart.AssemblyLinearVelocity
		local RaycastResult = Workspace:Raycast(Character.HumanoidRootPart.CFrame.Position, Vector3.new(0, -3, 0))

		if RaycastResult and RaycastResult.Instance then
			local Hit = RaycastResult.Instance

			if Hit.Name == "Head" or Hit.Name == "Torso" or Hit.Name == "HumanoidRootPart" or Hit.Name == "Handle" then
				
			end
		end
	end
end)

Any help would be appreciated, thanks!

its because youre raycasting from the players character to the position 0, -3, 0

local RaycastResult = Workspace:Raycast(Character.HumanoidRootPart.CFrame.Position, Character.HumanoidRootPart.CFrame.Position+Vector3.new(0, -3, 0))

Thank you, but i was wondering if there was a way to implement the logic where the player slips backwards

I guess you want them to just sit? Just set the Humanoid Sit Propert to true

this should work

RunService.RenderStepped:Connect(function()

	local Character = Player.Character or Player.CharacterAdded:Wait()

	if Character and Character:FindFirstChild("HumanoidRootPart") then
		local original = Character.HumanoidRootPart.AssemblyLinearVelocity
		local RaycastResult = Workspace:Raycast(Character.HumanoidRootPart.CFrame.Position, Vector3.new(0, -3, 0))

		if RaycastResult and RaycastResult.Instance then
			local Hit = RaycastResult.Instance

			if Hit.Name == "Head" or Hit.Name == "Torso" or Hit.Name == "HumanoidRootPart" or Hit.Name == "Handle" then
				Character.Humanoid.PlatformStand = true 
				task.wait()
				for i = 1, 10 do 
					Character.HumanoidRootPart.CFrame *= CFrame.Angles(math.rad(i*2), 0, 0)
					task.wait()
				end
				task.wait(0.6)
				Character.Humanoid.PlatformStand = false 
			end
		end
	end
end)

Thank you, but i dont want them to platform stand, i want them to slip backwards, kind of like a conveyor belt or ice

This is the code I have come up with but the raycast seems delayed and doesnt detect the player touching another players head unless you jump on it:


local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")

local Player = Players.LocalPlayer



RunService.Heartbeat:Connect(function()

	local Character = Player.Character or Player.CharacterAdded:Wait()

	if Character and Character:FindFirstChild("HumanoidRootPart") then
		local original = Character.HumanoidRootPart.AssemblyLinearVelocity
		local RaycastResult = Workspace:Raycast(Character.HumanoidRootPart.CFrame.Position, Vector3.new(0, -3, 0))

		if RaycastResult and RaycastResult.Instance then
			local Hit = RaycastResult.Instance

			if Hit.Name == "Head" or Hit.Name == "Torso" or Hit.Name == "HumanoidRootPart" or Hit.Name == "Handle" then
				Character.HumanoidRootPart.Velocity = Hit.CFrame.lookVector *-40
			end
		end
	end
end)