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

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

Asked by 6 years ago
Edited by Goulstem 6 years ago

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
0
Tab correctly in the future. Goulstem 8144 — 6y
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`. Goulstem 8144 — 6y
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. hiimgoodpack 2009 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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)
0
`script.Parent.Touched` is always going to return true. Goulstem 8144 — 6y
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! :) RaverKiller 668 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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)

Answer this question