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

01local UIS = game:GetService("UserInputService")
02local Players = game:GetService("Players")
03local ReplicatedStorage = game:GetService("ReplicatedStorage")
04 
05local camera = workspace.CurrentCamera
06local Player = Players.LocalPlayer
07local pathToThePart = ReplicatedStorage.Part
08 
09UIS.InputBegan:Connect(function(Key, Chatted)
10    if Chatted then
11        return
12    end
13    if Key.KeyCode == Enum.KeyCode.E then
14        local projectile = pathToThePart
15        projectile.Parent = workspace
16        projectile.CFrame = Player.Character.HumanoidRootPart.CFrame
17        projectile.BodyVelocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 1000
18    end
19end)

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:

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

Answer this question