Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

Log in to vote
0
Answered by
sifn 70
3 years ago

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
Ad

Answer this question