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

Player = game.Players.LocalPlayer
Character = Player.Character
Mouse = Player:GetMouse()
Enabled = true

Mouse.KeyDown:connect(function(key)
if Enabled == false then return end
    key = key:lower()
    if key == "q" then 
        Enabled = false
    Lightball = Instance.new("Part")
    Lightball.Shape = "Ball"
    Lightball.Material = "Neon"
    Lightball.Parent = Character
    Lightball.CFrame = Character.UpperTorso.CFrame*CFrame.new(0,0,-5)
    BV = Instance.new("BodyVelocity")
    BV.maxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = Character.UpperTorso.CFrame.lookVector*100
    BV.Parent = Lightball
    Dmg = script.Damage:Clone()
    Dmg.Parent = Lightball
    Dmg.Disabled = false






end

wait(2)
Enabled = true

end)

damage script

Player = game.Players.LocalPlayer

script.Parent.Touched:connect(function(hit)
if damage == false then return end
Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid.Parent == Player.Character then return end
Humanoid.Health = Humanoid.Health -20
damage = false
script.Parent.CanCollide = false
script.Parent.Transparency = 0.5
end)
 wait()
damage = 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 ScrubSadmir 200 — 6y
0
Thanks for that!!  Yonatann12 0 — 6y

Answer this question