Multiple Parts Touched

  1. What do you want to achieve? I want to make a script that a function happens not just to one but to mulitple parts!

  2. What is the issue? The issue is that I don’t know how to make a make a short version of the script…

  3. What solutions have you tried so far? I have looked in the topics in DevForum, but I couldn’t find what I wanted!

I’m making a DC Obby. There is a folder called “Checkpoints” and the parts are named by numbers. I want to make some parts do something and some other parts do something else. Sorry if I’m not making any sense :sweat_smile:.

2 Likes

You would use a for loop for this purpose and iterate through an Array of children with GetChildren, like this:

for i,v in Instance:GetChildren() do -- iterates through all children within an Item
    if v:IsA("BasePart") then -- if The Instance is a Part
        -- Apply Touch event
    end
     -- Apply The Touched Event for all BaseParts
end
2 Likes

Hi!
Sorry if I understood you incorrectly, but I believe you want something alike this example:

I have a folder with parts named part1 to part 10. I want the parts 1-4 to be destroyed, the parts 5-7 to go up a stud, and the parts 8-10 to become half transparent.

You can simply select and edit them like this:

local folder = workspace.Folder
local function change()
	for i = 1,4 do
		folder["part"..i]:Destroy()
	end
	for i = 5,7 do
		folder["part"..i].Position += Vector3.new(0,1,0)
	end
	for i = 8,10 do
		folder["part"..i].Transparency = 0.5
	end
end
change()

Does this give you an idea of what you could do?

2 Likes

Where did you put this script and is it local or normal :thinking:?

just a normal script, else the changes will only be for the client
You can place it wherever you want!

1 Like

I’m making a script for a textlabel, so do I put the script inside of the textlabel (I want to make players have their own ui if you know what I mean)?

It really doesn’t matter where you place it, as long as it is in the same ScreenGui. I usually just place it in the TextLabel to keep it clean. What do you want the script to do with the TextLabel if I may ask? That way i can edit the script for you if you’d like.

1 Like

I want the textlabel to change color and by the way, the DC stands for Difficulty Chart if you didn’t know :grin:. But you don’t need to make the script, I can do it by myself!

And one more question, do the parts need to go in order in the folder :face_with_raised_eyebrow:?

Oh I didn’t know indeed, that’s a very fun project! I wish you luck with your project. Do you mind sending me the name of the game so I can check it out some time?

1 Like

No the order does not matter. It’s aready enough if the parts are all named differently, else it will select only the first part every time.

1 Like

Oh, thank you for helping! And for the game, it’s called “RKG´s Difficulty Chart Obby” it’s a group-made game but I’m doing most of the work :joy:.

1 Like

Is the game out at the moment? Or else do you know when it will be published?

1 Like

The game is still not out at the moment, but it will be out this week for sure! And you’ll be the first to try out the game :grin: :+1:. (If you want, I can send some screenshots!)

1 Like

Sure, I’d like that!

I need to type this because else I can’t post this because of a lack of characters

Nice! But where do I send the screenshots cause I cannot post them here?

I believe you can paste or drag images into the message, just like i did here!
image





Here are four screenshots of the game. Rate the game 1 out of 5 and explain why did you rate [number] :laughing:!

2 Likes

Your script works well but it’s not what I asked for. Sorry if my post didn’t make any sense :face_with_diagonal_mouth:.

That looks amazing!
I’d give it a 4.5/5 because the game really looks fantastic, but the gui colors are a little dull to me. I think that if you’d change the gui color based on the player’s level, it would be a 5/5 to me. (If you do this, make it a little bit lighter or darker as seeing the same color everywhere might be confusing to the player.)
The colors are well chosen, they really fit into the type of game. There are also alot of gui options, which is great! The game looks like I could see it in between other popular DC’s. The images put in the gui are also smooth, and fit very well!

1 Like