Hard Written By BosOfroblox

CollectionService Created on: 24-07-2019

You will learn about CollectionService.

First of all, you need the plugin: Tag Editor

When you've install the plugin, go back to studio go to Plugins.

Click on the Tag Window, which will show you this new Bar.

Inside this bar, you need to click on Add New Tag call the tag: Doors When you've added the new tag, create a part which is the size 9,9,1 Call the Part door, and dupe as many as you want. Place the doors random places

Now you have to select the parts/doors you've created, and click on the tag so that they get tagged as Doors .

Now go to ServerScriptService create a script, call the script anything.

Go into your script you've just made, and type this

local CS = game:GetService("CollectionService")
local Tagged = CS:GetTagged("Doors")

CS/CollectionService you need to get it's Service so you can use it later on for finding the tags like i did by doing

local Tagged = CS:GetTagged("Doors")

When you've added does you need to make a for loop. If you don't know how for loops works, you need to learn/understand it first.

local CS = game:GetService("CollectionService")
local Tagged = CS:GetTagged("Doors")

for _, Tagged in pairs(Tagged) do


end

this will loop thru your Tagged parts.

Now for the easy part, by using a Touched Function.

local CS = game:GetService("CollectionService")
local Tagged = CS:GetTagged("Doors")

for _, Tagged in pairs(Tagged) do

	Tagged.Touched:connect(function(hit)
		local humanoid = hit.Parent:FindFirstChild("Humanoid")
		
		if humanoid then
			Tagged.Transparency = 1
			Tagged.CanCollide = false
			wait(3)
			Tagged.CanCollide = true
			Tagged.Transparency = 0
		end
		
	end)

end

reason i've done Tagged.Transparency = 1 and Tagged.CanCollide = false is because the for loop is looping thru the tagged parts which will then choose the one you've touched, and will not do it on the other parts.

Hope you've learned something today ^^

Hard Written By BosOfroblox

See BosOfroblox's profile on Roblox

Discussion