Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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 comment

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)

2 answers

✓ Accepted answer

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)

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.