Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

BodyVelocity is not a valid member of Part "Workspace.Part"?

so i have a spawn part script but there is a error saying "BodyVelocity is not a valid member of Part "Workspace.Part" " here is my script

local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local camera = workspace.CurrentCamera
local Player = Players.LocalPlayer
local pathToThePart = ReplicatedStorage.Part

UIS.InputBegan:Connect(function(Key, Chatted)
	if Chatted then
		return
	end
	if Key.KeyCode == Enum.KeyCode.E then
		local projectile = pathToThePart
		projectile.Parent = workspace
		projectile.CFrame = Player.Character.HumanoidRootPart.CFrame
		projectile.BodyVelocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 1000
	end
end)

1 answer

✓ Accepted answer

Are you sure there's a BodyVelocity object inside of the part? BodyVelocity is not a property, it's a physical object that you must insert into the part. If you're sure it's there, try projectile:WaitForChild("BodyVelocity")

Also, I notice that you are not setting the velocity properly. A BodyVelocity object has a Velocity property which is what you want to modify. Write it like this:

projectile.BodyVelocity.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 1000

This discussion is preserved as it was. New answers, comments, and votes are closed.