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 5 years ago
Edited 5 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.CanCollide = false
    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




    wait(2)

end


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

0
code blocks please User#23365 30 — 5y
0
also keydown is decaperated use InputBegan from UserInputService User#23365 30 — 5y
0
you are setting properties of a part with a local script which doesn't work in an FE game theking48989987 2147 — 5y
0
to make it float forever, first anchor it and then set the velocity to the player's look vector theking48989987 2147 — 5y
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 — 5y
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 — 5y
0
By anchoring it, the "light-ball" stays still Yonatann12 0 — 5y

Answer this question