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

My Tool For A Firing Projectile Not Working? (SOLVED PLEASE CLOSE)

Asked by 9 years ago

Hello and thank you for taking you time to look at my question, I'll get straight to the point; My local script which is inside StarterPack and the parent of the local script is named pistol which used to be tool. I also have a part in the tool, which is pistol and the part is called Handle, and it has a mesh in it. I named all of this to see if they're causing the error. Here's the code!

Player = game.Players.LocalPlayer

Gun = script.Parent

Ammo = 5

function Shoot()

    if Ammo > 0 then
        Local Bullet = Instance.new("Part", Workspace)
        Bullet.Shape = "Ball"--The Bullet is the error part.
    end

end

So the Bullet error gets a blue line under it, saying try putting local in front of Bullet to make it better. I try to put local in front of the error Bullet, but it gets an error saying 'expected '=' got 'Bullet'' I have no idea what's going on, I had to stop script production because of this error. Can you help me? If you can help me, that'll be great! Thank you and have a nice day!

1 answer

Log in to vote
4
Answered by 9 years ago

Local needs to be lowercased on line 10. Try this script:

Player = game.Players.LocalPlayer

Gun = script.Parent

Ammo = 5

function Shoot()

    if Ammo > 0 then
        local Bullet = Instance.new("Part", Workspace)
        Bullet.Shape = "Ball"
    end

end

Why this gave the error you described : The error showed up as 'expected "=" got "Bullet"' because it thought local was a variable. This is just like in line 1 and 3 where you used no 'local'. Capitalization counts on things like this. When you look over your script, you should notice that 'Local' is not being recognized as a keyword. Keywords are special words that cannot be used as variable names or function names, and control the flow of the script. Keywords are bolded in a dark blue color. Below are some other keywords. - if - else - elseif - for - while - break - next - not - true - false - then - end - function - local

If my answer helped you, accept and upvote it.

0
Awesome! Your answer really helped me, alot. I could've of saw the answer myself! I guess 10 hours straight of nothing but Lua can make you miss that. Thank you for your help, I'll upvote and accept your answer for pointing that out. GreekGodOfMLG 244 — 9y
1
No problem! That's what we're here for. SchonATL 15 — 9y
Ad

Answer this question