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

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

Asked by 4 years ago
Edited 4 years ago

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 <string> but got ':' "

0
add parenthesis after destroy: for example, function destroy(). Fifkee 2017 — 4y
0
Okay, thanks spoonses 7 — 4y
0
Hey, I see that you changed my answer from accepted to not accepted. Are you having any issues with the code? royaltoe 5144 — 4y
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. royaltoe 5144 — 4y

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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

0
Okay, thanks spoonses 7 — 4y
Ad

Answer this question