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
01 | local UIS = game:GetService( "UserInputService" ) |
02 | local Players = game:GetService( "Players" ) |
03 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
04 |
05 | local camera = workspace.CurrentCamera |
06 | local Player = Players.LocalPlayer |
07 | local pathToThePart = ReplicatedStorage.Part |
08 |
09 | UIS.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 |
19 | end ) |
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:
1 | projectile.BodyVelocity.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 1000 |