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

More Fireball Help: Recharge And Explosion (Collide) Assistance?

Asked by
Jxemes 75
7 years ago

I got some help yesterday on my fireball script, and turns out I made a few errors. I got help and It was fixed. I would like the fireball be similar to Elemental Battlegrounds' Fireball. Now I'm trying to experiement of how to make a wait function "wait(5)" so you won't be able to spam the spell. It won't work, and I don't know why, and I made an explode model instead of using ROBLOX's default explosion. So I need help. Here's what I have.

local me = game.Players.LocalPlayer
local tool = script.Parent
local ws = game:GetService("Workspace")

tool.Equipped:connect(function(mouse)
    mouse.Button1Down:connect(function()
        handle = me.Character:FindFirstChild("Torso")
        if handle== nil then
            handle=me.Character.UpperTorso
            end
        local p = Instance.new("Part")
        p.CFrame = CFrame.new(handle.Position)
        p.TopSurface = "Smooth"
        p.BottomSurface = "Smooth"
        p.Shape = Enum.PartType.Ball
        p.Size = Vector3.new(1,1,1)
        p.CanCollide = false
        p.BrickColor = BrickColor.new("Really red")
        p.Parent = ws
        local bv = Instance.new("BodyVelocity")
        bv.Parent = p
        bv.velocity = (mouse.Hit.p - handle.Position).unit*90
        p.Touched:connect(function(hit)
            if hit.Parent.Name ~= me.Character.Name then
                hit.Parent.Humanoid:TakeDamage(5)
            end
        end)
        game:GetService("Debris"):AddItem(p, 7)
    end)
end)

Got any tips, ideas or hints? Thanks for the help.

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

Here's the issue for your cooldown, you must use a debounce function. It would help out greatly, because if you use the wait, you can still spam it, but the spam will be delayed to 5 seconds after. Here is your script with debounce implemented:

local me = game.Players.LocalPlayer
local tool = script.Parent
local ws = game:GetService("Workspace")
local debounce = false

tool.Equipped:connect(function(mouse)
    mouse.Button1Down:connect(function()
    if not debounce then
    debounce = true
        handle = me.Character:FindFirstChild("Torso")
        if handle== nil then
            handle=me.Character.UpperTorso
            end
        local p = Instance.new("Part")
        p.CFrame = CFrame.new(handle.Position)
        p.TopSurface = "Smooth"
        p.BottomSurface = "Smooth"
        p.Shape = Enum.PartType.Ball
        p.Size = Vector3.new(1,1,1)
        p.CanCollide = false
        p.BrickColor = BrickColor.new("Really red")
        p.Parent = ws
        local bv = Instance.new("BodyVelocity")
        bv.Parent = p
        bv.velocity = (mouse.Hit.p - handle.Position).unit*90
        p.Touched:connect(function(hit)
            if hit.Parent.Name ~= me.Character.Name then
                hit.Parent.Humanoid:TakeDamage(5)
        wait(5)
        debounce = false
            end
        end)
        game:GetService("Debris"):AddItem(p, 7)
    end)
end)

Make sure to notify me if this does not work!

0
It works, but made a new problem, I typed it on my answers, so what the error is, is whenever the ball hits the Baseplate or something without a humanoid, it will not recharge. Jxemes 75 — 7y
Ad
Log in to vote
0
Answered by
Jxemes 75
7 years ago

Humanoid is not a valid member of Workspace 17:51:03.295 - Stack Begin 17:51:03.297 - Script 'Players.Player1.Backpack.Fireball.Main', Line 32

Answer this question