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

Why is this error coming "unexpected symbol near ')' " ?

I simply want to know why this code does not work, the error is in the title, here is the script(The error is in line 41):

tool = script.Parent
player = game.Players.LocalPlayer
mouse = player:GetMouse()
reload = true
tool.Activated:connect(function()
	if reload == true then
		reload = false
		local Part = Instance.new("Part", workspace)
	Part.Size = Vector3.new(0.1,0.1,0.1)
	Part.Shape = ("Ball")
	Part.Position = Vector3.new(-3.5,0.5,4.5)
	Part.CFrame = tool.Handle.CFrame
	Part.CFrame = CFrame.new(Part.Position,mouse.Hit.p)
	local v = Instance.new("BodyVelocity", Part)
	v.velocity = Part.CFrame.lookVector *90
	v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
	Part.Touched:connect(function(hit)

		if hit.Name == "Snow" then
			local Snow = hit
			Snow.Transparency = 0.1
			wait(0.1)
			Snow.Transparency = 0.2
			wait(0.1)
			Snow.Transparency = 0.3
			wait(0.1)
			Snow.Transparency = 0.4
			wait(0.1)
			Snow.Transparency = 0.5
			wait(0.1)
			Snow.Transparency = 0.6
			wait(0.1)
			Snow.Transparency = 0.7
			wait(0.1)
			Snow:Destroy()
			Part:Destroy()
		end	
	end)
	wait(3)
	reload = true
	end)

1 answer

✓ Accepted answer

Count your ends

Also consider indenting your code properly. You're missing an end for the if statement just inside of your first event connection.

tool = script.Parent
player = game.Players.LocalPlayer
mouse = player:GetMouse()
reload = true
tool.Activated:connect(function()
    if reload == true then
        reload = false
        local Part = Instance.new("Part", workspace)
		-- What happened to this indent?
    Part.Size = Vector3.new(0.1,0.1,0.1)
    Part.Shape = ("Ball")
    Part.Position = Vector3.new(-3.5,0.5,4.5)
    Part.CFrame = tool.Handle.CFrame
    Part.CFrame = CFrame.new(Part.Position,mouse.Hit.p)
    local v = Instance.new("BodyVelocity", Part)
    v.velocity = Part.CFrame.lookVector *90
    v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
    Part.Touched:connect(function(hit)

        if hit.Name == "Snow" then
            local Snow = hit
            Snow.Transparency = 0.1
            wait(0.1)
            Snow.Transparency = 0.2
            wait(0.1)
            Snow.Transparency = 0.3
            wait(0.1)
            Snow.Transparency = 0.4
            wait(0.1)
            Snow.Transparency = 0.5
            wait(0.1)
            Snow.Transparency = 0.6
            wait(0.1)
            Snow.Transparency = 0.7
            wait(0.1)
            Snow:Destroy()
            Part:Destroy()
        end 
    end)
    wait(3)
    reload = true
	end
end)

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