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

Why is this code block wrong? Trying to deal damage when punching somebody.

tool.Equipped:Connect(function()
	if hum.Health <= 0 then return end
	idle:Play()
	b1d = mouse.Button1Down:Connect(function()
		if hum.Health <= 0 then return end
		if deb == false then deb= true
		if on == false then on = true
			anim1:Play()
			throw.Pitch = math.random(1,2)
			throw:Play()
			if msp:UserOwnsGamePassAsync(plr.UserId, gamepassid) then
				plr.PlayerStats.EXP.Value = plr.PlayerStats.EXP.Value + 50
			else plr.PlayerStats.EXP.Value = plr.PlayerStats.EXP.Value + 25
			local mydeb = false
			rht = rh.Touched:Connect(function(hit)
				if hum.Health <= 0 then return end
				if mydeb == false then mydeb = true
							if hit.Parent:FindFirstChild("Humanoid") then
									pE:InvokeServer(hit.Parent:FindFirstChild("Humanoid"), dmg, hit)
							end)
						end
						end)
					end
				end
			end
			end
		end)
end
end
end

the first end) has an error saying "expected identifier when parsing expression, got ')'"

what is wrong with this code block?

1 answer

Well, do understand the difference between end and end). end is generally used for closing non-function statements or non-connecting functions. E.G.:

if a == b then
	print("Hey!")
end -- if statement is a non-function statement

function a()
	print("HMM!)
end -- function a() is a non-connecting function

end) is generally used to close connecting functions.

script.Parent.Activated;Connect(function()
	print("Hey")
end) -- First line is a connecting function

Also, you have to close all the statements in a connecting function before closing the connecting function.

script.Parent.Touched:Connect(function()
	if a == b then
		print("Hey")
	end -- Closing if statement first
end) -- Closing the connecting function at the end

Now, you know the difference between the 'ends', now you edit your script and make it work!

Lemme know if it helps!

4 comments

0

It's not necessarily that 'end' and 'end)' are two different things. 'end' ends stuff like functions, if statements, loops, etc., the other one does the same thing, but also has a closing parenthesis after it. In the case of connecting a function to an event, you put 'end' to end the function and the ')' part just closes off the opening parenthesis at ":Connect(". Other than that, a good explanati

0

i thought i had it after you explained but it still is not working.

0

i thought i had it after you explained but it still is not working.

0

Well, the easiest way to solve your problem is reweite your own code. When you will press enter, Roblox will automatically add the correct end.

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