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

Why doesn't the body velocity in the "Plasma Blast" work after you used it once?

Asked by 10 years ago

There's nothing wrong with this script. The problem is when I use it once, and I try use it again, the blast will stay in one spot.

Script:

plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
dmg = script.Damage
unlocked = plr.PlasmaC.Value
debounce = true

mouse.KeyDown:connect(function(spell)
    if spell == "e" and unlocked == true and debounce == true then
        debounce = false
        print("PlasmaCannon")
        game:GetService("Chat"):Chat(plr.Character.Head, "Plasma Cannon!")
        p = Instance.new("Part", workspace)
        game.Debris:AddItem(p, 6)
        p.Shape = "Ball"
        p.Size = Vector3.new(10,10,10)
        p.Name = "PlasmaCannon"
        p.TopSurface = "Smooth"
        p.BottomSurface = "Smooth"
        p.CanCollide = false
        p.BrickColor = BrickColor.new("Bright blue")
        p.Transparency = .2
        p.Anchored = false
        f = Instance.new("Fire", p)
        f.Size = 24
        f.Heat = 11
        f.Color = Color3.new(0, 55, 255)
        f.SecondaryColor = Color3.new(0, 31, 145)
        v = Instance.new("BodyVelocity", p)
        v.velocity = plr.Character.Torso.CFrame.lookVector*90
        v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        p.CFrame = plr.Character.Torso.CFrame*CFrame.new(0, 0, -12)
    end
    wait(0.7)
    debounce = true
end)
1
Warning: `Color3.new` uses numbers 0 to 1, not 0 to 255. E.g., Color3.new(0, 55, 255) should really be `Color3.new(0, .215, 1)` BlueTaslem 18071 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

Try this. The mistake you made was that the script possibly made the script of parenting the velocity to the old projectile. Making "p", "f", and "v" local variable helps.

plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
dmg = script.Damage
unlocked = plr.PlasmaC.Value
debounce = true

mouse.KeyDown:connect(function(spell)
    spell = spell:lower()
    if spell == "e" and unlocked and debounce then
        debounce = false
        print("PlasmaCannon")
        game:GetService("Chat"):Chat(plr.Character.Head, "Plasma Cannon!")
        local p = Instance.new("Part", workspace)
        game.Debris:AddItem(p, 6)
        p.Shape = "Ball"
        p.Size = Vector3.new(10,10,10)
        p.Name = "PlasmaCannon"
        p.TopSurface = "Smooth"
        p.BottomSurface = "Smooth"
        p.CanCollide = false
        p.BrickColor = BrickColor.new("Bright blue")
        p.Transparency = .2
        p.Anchored = false
        p:BreakJoints()
        local f = Instance.new("Fire", p)
        f.Size = 24
        f.Heat = 11
        f.Color = Color3.new(0, 55, 255)
        f.SecondaryColor = Color3.new(0, 31, 145)
        local v = Instance.new("BodyVelocity", p)
        v.velocity = plr.Character.Torso.CFrame.lookVector*90
        v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        p.CFrame = plr.Character.Torso.CFrame*CFrame.new(0, 0, -12)
        wait(0.7)
        debounce = true
    end
end)

Ad
Log in to vote
-1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

Just move this code;

wait(0.7)
debounce = true

Into the If Then statement.

plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
dmg = script.Damage
unlocked = plr.PlasmaC.Value
debounce = true

mouse.KeyDown:connect(function(spell)
    if spell == "e" and unlocked == true and debounce == true then
        debounce = false
        print("PlasmaCannon")
        game:GetService("Chat"):Chat(plr.Character.Head, "Plasma Cannon!")
        p = Instance.new("Part", workspace)
        game.Debris:AddItem(p, 6)
        p.Shape = "Ball"
        p.Size = Vector3.new(10,10,10)
        p.Name = "PlasmaCannon"
        p.TopSurface = "Smooth"
        p.BottomSurface = "Smooth"
        p.CanCollide = false
        p.BrickColor = BrickColor.new("Bright blue")
        p.Transparency = .2
        p.Anchored = false
        f = Instance.new("Fire", p)
        f.Size = 24
        f.Heat = 11
        f.Color = Color3.new(0, 55, 255)
        f.SecondaryColor = Color3.new(0, 31, 145)
        v = Instance.new("BodyVelocity", p)
        v.velocity = plr.Character.Torso.CFrame.lookVector*90
        v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        p.CFrame = plr.Character.Torso.CFrame*CFrame.new(0, 0, -12)
        wait(0.7)
        debounce = true
    end
end)

Answer this question