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

I got this error code and im wondering how i can fix this script?

Script

local brick = script.Parent
brick.Changed:connect(function()
	if brick.Velocity.magnitude > 2 then
		if script.Parent.Touched then
			brick:Breakjoints()
		end
	end
end

Error code

18:19:14.977 - Workspace.Part.Script:8: ')' expected (to close '(' at line 2) near '<eof>'

thank you for your time

######Edited 15:41 11/8/17

3 comments

0

Tab correctly in the future.

1

The error means that you need a parenthesis after the last end. And Touched is not a property - it is an event that triggers, like Changed.

1

Adding onto Goulstem, eof just means end of file, or in this case, end of the script. You make a new function for one of the arguments, but forgot to close the argument list.

2 answers

When you are using an anonymous function you require a ')' at the end to close the connection that you have opened.

EDIT: Just read the rest of your code too after a comment pointing it out as I initially only searched for the error you posted, I assume that this is your goal:

local brick 	=	script.Parent

brick.Touched:Connect(function()
	if brick.Velocity.Magnitude > 2 then
		brick:BreakJoints()
	end
end)

2 comments

0

script.Parent.Touched is always going to return true.

0

My bad @Goulstem, only looked for his initial error - I've gone back and edited it to what I'm assuming he is actually after, good spot! :)

thank you so much heres the advanced break joints script that doesnt kill the character,or remove the accessorys and will only break if it hits a object at a certain speed


script.Parent.Touched:Connect(function(part)
	local h = part.Parent:findFirstChild("Humanoid")
	local g = part.Parent.Parent:findFirstChild("Head")
	local s = script.Parent.Velocity.Magnitude
	if h==nil then if g==nil then if s>0.001 then
        part:BreakJoints()
			end
		end
	end
end)

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