Hello so I recently tried to make a script that would clone a part in front of u then make it go in the same direction u are facing but I failed and i don't know how to fix it. Part with problem is written in the script with " -- Part with problem" along with explanation
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(chr) plr.Chatted:connect(function(msg) if plr.Name == "My username." then if msg == "Red" then local hi = game.Workspace.AlexTest.boio:Clone() hi.Parent = chr hi.CFrame = chr.Torso.CFrame * CFrame.new(0,0,-5) hi.Orientation = chr.Torso.Orientation - Vector3.new(0,90,0) hi.Name = "Red" hi.Anchored = false chr.Humanoid.WalkSpeed = 0 -- ^ clone the tool, bring it in front of my torso facing the same direction as my torso. hi.p.Position = Vector3.new(chr.Torso.CFrame * CFrame.new(0,0,-5000)) -- Part with problem. --https://gyazo.com/bf847c8fdbe6deb1fee00dd9f8e20156 -- this is what happens. chr.Humanoid.WalkSpeed = 16 wait(10) hi:Destroy() end end end) end) end)
There are 2 problems.
Note: hi.p is a BodyPosition.
You don't wanna use bodyposition to make something move to a specified point, you wanna use bodyvelocity like this
local bv = Instance.new("BodyVelocity", x) -- x being the part its being parented to bv.MaxForce = Vector3.new(1e8, 1e8, 1e8) bv.Velocity = root.CFrame.lookVector * 80 -- root obviously being the players root, youd need to define the players root for this line to work
adding this should make something move forward as a projectile