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

Can somebody help me fix my fireball script? Im having a error towards the bottom at the End)

Asked by 7 years ago
Edited by OldPalHappy 7 years ago

i made this script that shoots out fireballs but its not working, can someone tell me what i did wrong?

local Tool = script.Parent
play = Tool.Parent.Parent
mouse = play:GetMouse()
char = play.Character
hum = char.Humanoid
root = char.HumanoidRootPart

local en = true

Tool.RemoteEvent.OnServerEnevent:connect(function(play,mousehit)
    local a = hum:LoadAnimation(Tool.Throw)
    a:Play()
    wait(0.7)
    root.CFrame = CFrame.new(root.Position,root.Postition + Vector3.new(mousehit.lookVector.x,0,mousehit.lookVector.z))
    local fireball = Tool.Handle:clone()
    fireball.CFrame = Tool.Handle.CFrame
    local bv = Instance.new("BodyVelocity")
    bv.MaxForce = Vector3.new(1e8,1e8,1e8)
    bv.Velocity = mousehit.lookVector * 50
    bv.Parent = fireball
    fireball.CanCollide = false
    fireball.Parent = game.Workspace
    game.Debris:AddItem(fireball,4)
    local ten = true
    fireball.Touched:connect(function(hit)
        if not ten then return end
        ten = false
        local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
        if ehum then
            if ehum and ehum ~= hum then
            ehum:TakeDamage(10)
            elseif hit.Anchored == true and  hit.CanCollide == true then
                for i=i,10 do
                    local part = fireball:clone()
                    part.Size = Vector3.new(0.5,0.5,0.5)
                    part.CFrame = fireball.CFrame
                    part.BodyVelocity.MaxForce = Vector3.new(1e8,0,1e8)
                    part.ParticleEmitter.LockedToPart = false
                    part.BodyVelocity.Veloctiy = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30))
                    part.Parent = game.Workspace
                    game.Debris:AddItem(part,1)
             end
        end

        wait()
        ten = true

        end)


end)
0
I added your code in a code block. In the future, please do this yourself: https://forum.scriptinghelpers.org/topic/82/how-to-format-questions-answers-on-the-main-site OldPalHappy 1477 — 7y
0
do you know the problem with it? bennacho570 0 — 7y
0
you cared enough to put it in boxes, but not to actually take a look and see the problem. bennacho570 0 — 7y

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

TAB YOUR CODE CORRECTLY!!

The error was quite obious once the code was tabbed correctly. You neglected to close your if statement on line 29.

Also, you made a typo on line 10. "OnServerEnevent" should be "OnServerEvent".

local Tool = script.Parent
local play = Tool.Parent.Parent
local mouse = play:GetMouse()
local char = play.Character
local hum = char.Humanoid
local root = char.HumanoidRootPart
local en = true

Tool.RemoteEvent.OnServerEvent:connect(function(play,mousehit)
    local a = hum:LoadAnimation(Tool.Throw)
    a:Play()
    wait(0.7)
    root.CFrame = CFrame.new(root.Position,root.Postition + Vector3.new(mousehit.lookVector.x,0,mousehit.lookVector.z))
    local fireball = Tool.Handle:clone()
    fireball.CFrame = Tool.Handle.CFrame
    local bv = Instance.new("BodyVelocity")
    bv.MaxForce = Vector3.new(1e8,1e8,1e8)
    bv.Velocity = mousehit.lookVector * 50
    bv.Parent = fireball
    fireball.CanCollide = false
    fireball.Parent = game.Workspace
    game.Debris:AddItem(fireball,4)
    local ten = true
    fireball.Touched:connect(function(hit)
        if not ten then return end
        ten = false
        local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
        if ehum then
            if ehum and ehum ~= hum then
                ehum:TakeDamage(10)
            elseif hit.Anchored and hit.CanCollide then
                for i = i, 10 do
                    local part = fireball:Clone()
                    part.Size = Vector3.new(0.5,0.5,0.5)
                    part.CFrame = fireball.CFrame
                    part.BodyVelocity.MaxForce = Vector3.new(1e8,0,1e8)
                    part.ParticleEmitter.LockedToPart = false
                    part.BodyVelocity.Veloctiy = Vector3.new(
                        math.random(-30,30),
                        math.random(-30,30),
                        math.random(-30,30)
                    )
                    part.Parent = workspace
                    game.Debris:AddItem(part,1)
                end
            end
            wait()
            ten = true
        end
    end)
end)
0
Thank you so much! <3 bennacho570 0 — 7y
0
Remember to accept my answer if it helped you. It ensures both the asker and the answerer recieve the reputation they deserve. Goulstem 8144 — 7y
Ad

Answer this question