Knock-back whenever I throw a projectile and jump? I've listed what I've tried
Asked by
6 years ago Edited 6 years ago
so I've spent some time making a projectile script but whenever I would press "q" and jump I would be flung some distance and especially when I press q and jump in the direction of the "Lightball."
Becuase of this, I tried turning the can-collide off, as with it on you'd get pushed. without "can collide" if you jump and press q, the part (Light ball) will be shot through the ground and not in the direction I want it to go, straight.
One last thing. I also get an error on the damage script down bellow on line 6 which is if Humanoid.Parent == Player.Character then return end and the error is
07:17:42.917 - Workspace.Yonatann12.Part.Damage:6: attempt to index global 'Humanoid' (a nil value) Although I've had no problems With how the damage script has run
the projectile script is inside the Starter Pack and the damage script is inside the projectile script.
Projectile
01 | Player = game.Players.LocalPlayer |
02 | Character = Player.Character |
03 | Mouse = Player:GetMouse() |
06 | Mouse.KeyDown:connect( function (key) |
07 | if Enabled = = false then return end |
11 | Lightball = Instance.new( "Part" ) |
12 | Lightball.Shape = "Ball" |
13 | Lightball.Material = "Neon" |
14 | Lightball.Parent = Character |
15 | Lightball.CFrame = Character.UpperTorso.CFrame*CFrame.new( 0 , 0 ,- 5 ) |
16 | BV = Instance.new( "BodyVelocity" ) |
17 | BV.maxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
18 | BV.Velocity = Character.UpperTorso.CFrame.lookVector* 100 |
20 | Dmg = script.Damage:Clone() |
21 | Dmg.Parent = Lightball |
end)
damage script
01 | Player = game.Players.LocalPlayer |
03 | script.Parent.Touched:connect( function (hit) |
04 | if damage = = false then return end |
05 | Humanoid = hit.Parent:FindFirstChild( "Humanoid" ) |
06 | if Humanoid.Parent = = Player.Character then return end |
07 | Humanoid.Health = Humanoid.Health - 20 |
09 | script.Parent.CanCollide = false |
10 | script.Parent.Transparency = 0.5 |
New information: I've found out that the reason I'm being knocked back is because the "Lightball" is hitting the ground and rolling. I don't know why it knocks me back but if a light-ball is rolling and I jump, I will be flung. Is there a way I can make it stop rolling and go straight forever? it doesn't roll until it's pretty far away?. Im fine with it rolling as long as I don't get knocked back though.