Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

01Player = game.Players.LocalPlayer
02Character = Player.Character
03Mouse = Player:GetMouse()
04Enabled = true
05 
06Mouse.KeyDown:connect(function(key)
07if Enabled == false then return end
08    key = key:lower()
09    if key == "q" then
10        Enabled = false
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)
View all 32 lines...

end)

damage script

01Player = game.Players.LocalPlayer
02 
03script.Parent.Touched:connect(function(hit)
04if damage == false then return end
05Humanoid = hit.Parent:FindFirstChild("Humanoid")
06if Humanoid.Parent == Player.Character then return end
07Humanoid.Health = Humanoid.Health -20
08damage = false
09script.Parent.CanCollide = false
10script.Parent.Transparency = 0.5
11end)
12 wait()
13damage = true

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.

0
the end) is the last part in the projectile script Yonatann12 0 — 6y
0
In your first script, the wait() has to be inside the function for the debounce of Enabled to actually work User#22980 0 — 6y
0
Thanks for that!!  Yonatann12 0 — 6y

Answer this question