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

[SOLVED] I'm trying to change a property of a part in a function but I can't?

I am a noob sorry I'm trying to change the properties of some parts within a function:

local function destroy
	script.Parent.Parts.Part1.Anchored = false
end

It underlines the first period in red when I write it and says "void destroy(with the code that I wrote)"


Okay, it solved the problem with the function, and now I'm trying to type an event after the function to trigger the function, but it underlines it in red. Do you know how to fix this?

local function destroy()
	parts.Anchored = false
end

script.Parent.InvisibleBlock:Touched:Connect

in the output, it says: "expected '(,' '{' or but got ':' "

4 comments

0

add parenthesis after destroy: for example, function destroy().

0

Okay, thanks

0

Hey, I see that you changed my answer from accepted to not accepted. Are you having any issues with the code?

0

Just saw your edit. If you have any more questions. Feel free to leave them in the comments of my answer and I can address them. I won't see them if you edit your post but I will see a notification if you comment on this post so make sure to do that instead.

1 answer

✓ Accepted answer

add parenthesis next to destroy

local function destroy()
    script.Parent.Parts.Part1.Anchored = false
end

Edit here is how you would do the second part of your problem: script.Parent.InvisibleBlock:Touched:Connect(destroy)

If you want to learn a bit more about functions, you can check out this article: https://developer.roblox.com/en-us/articles/Function

1 comment

0

Okay, thanks

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