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

Knockback when I shoot my projectile and jump?

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 Player = game.Players.LocalPlayer Character = Player.Character Mouse = Player:GetMouse() Enabled = true

01Mouse.KeyDown:connect(function(key)
02if Enabled == false then return end
03    key = key:lower()
04    if key == "q" then
05        Enabled = false
06    Lightball = Instance.new("Part")
07    Lightball.Shape = "Ball"
08    Lightball.Material = "Neon"
09    Lightball.Parent = Character
10    Lightball.CanCollide = false
11    Lightball.CFrame = Character.UpperTorso.CFrame*CFrame.new(0,0,-5)
12    BV = Instance.new("BodyVelocity")
13    BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
14    BV.Velocity = Character.UpperTorso.CFrame.lookVector*100
15    BV.Parent = Lightball
View all 30 lines...

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?. I'm fine with it rolling as long as I don't get knocked back though.

0
code blocks please User#23365 30 — 6y
0
also keydown is decaperated use InputBegan from UserInputService User#23365 30 — 6y
0
you are setting properties of a part with a local script which doesn't work in an FE game theking48989987 2147 — 6y
0
to make it float forever, first anchor it and then set the velocity to the player's look vector theking48989987 2147 — 6y
View all comments (3 more)
0
I've made the code blocks and I'll try to use InputBegan from UserInputService. I'll also try anchoring and then setting the velocity to the players look vector. Yonatann12 0 — 6y
0
if I turn collide false it goes through the ground when I run, do I have to change my running animation or can I change where my "Lightball.Cframe" is to fix this? Yonatann12 0 — 6y
0
By anchoring it, the "light-ball" stays still Yonatann12 0 — 6y

Answer this question