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

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

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

✓ Accepted answer

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.

2 comments

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.

1

No problem! That's what we're here for.

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