with my script i create a sphere with a body velocity, his X position and Z position works very well, but Y position doesn't work, i already created a script that move my torso to the direction that im clicking, but the body velocity still not working, somebody can help me?
local rs = game:GetService("ReplicatedStorage") local event = Instance.new("RemoteEvent", rs) event.Name = "GenkiDama" local function FiredEvent(player) local character = game.Workspace:WaitForChild(player.Name) wait(.1) local ki = Instance.new("Part") ki.Size = Vector3.new(40,40,40) ki.Size = ki.Size+Vector3.new(.42,.42,.42) ki.Shape = "Ball" ki.Name = "Energy" ki.CanCollide = false ki.BrickColor = BrickColor.new("Cyan") ki.Material = "Neon" ki.Parent = character ki.CFrame = character.HumanoidRootPart.CFrame*CFrame.new(0,0,-45) ki.CFrame = character.Torso.CFrame*CFrame.new(1, 1, -3) local bv = Instance.new("BodyVelocity", ki) bv.maxForce = Vector3.new(math.huge, math.huge, math.huge) bv.velocity = character.HumanoidRootPart.CFrame.lookVector*120 game.Debris:AddItem(ki, 9) local sound = Instance.new("Sound") sound.SoundId = "rbxassetid://586187912" sound.Parent = ki sound:Play() wait(0.2) local dmg = script.Damage:Clone() dmg.Parent = ki end event.OnServerEvent:Connect(FiredEvent)
I think it isn't working because of the 'bv.velocity' needing to have a capital V, as referencing things in Lua is case-sensitive.
You should also set the P property of the body velocity to something high if the ball goes through the ground when you spawn it.
On a side note, you can reference character by just doing
local character = player.Character
Also, the script will error at line 19 if you're using r15 characters, which you're probably not.
On Line 21, bv.maxForce
needs to become bv.MaxForce
and on Line 22 bv.velocity
needs to become bv.Velocity
since otherwise, you are not properly referencing the Properties of "bv"
Revised:
local rs = game:GetService("ReplicatedStorage") local event = Instance.new("RemoteEvent", rs) event.Name = "GenkiDama" local function FiredEvent(player) local character = game.Workspace:WaitForChild(player.Name) wait(.1) local ki = Instance.new("Part", character) ki.Size = Vector3.new(40,40,40) ki.Size = ki.Size + Vector3.new(.42,.42,.42) ki.Shape = "Ball" ki.Name = "Energy" ki.CanCollide = false ki.BrickColor = BrickColor.new("Cyan") ki.Material = "Neon" ki.CFrame = character.HumanoidRootPart.CFrame*CFrame.new(0,0,-45) ki.CFrame = character.Torso.CFrame*CFrame.new(1, 1, -3) local bv = Instance.new("BodyVelocity", ki) bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge) bv.Velocity = character.Torso.CFrame.lookVector*60 game.Debris:AddItem(ki, 9) local sound = Instance.new("Sound", ki) sound.SoundId = "rbxassetid://586187912" sound:Play() wait(0.2) local dmg = script.Damage:Clone() dmg.Parent = ki end event.OnServerEvent:Connect(FiredEvent)
Also, when you create a new instance, you can set the Parent of the Instance without having to add another line of code by simply changing
local sound = Instance.new("Sound") sound.Parent = ki
to
local sound = Instance.new("Sound", ki)
The only other possible error after this is to make sure that the script.Damage
is not nil