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

Why isin't this set transparency brick working?


local Part = script.Parent

local EndParts = {game.Workspace.TEndPart, game.Workspace.DEndPart, game.Workspace.Neon1EndPart, game.Workspace.DessertEndPart, game.Workspace.ASHEndPart}

Part.Touched:Connect(function()
		for _, object in pairs (EndParts) do
		object.Transparency = 1
		object.CanCollide = false
		wait(60)
	    object.Transparency = 0
		object.CanCollide = true
		end
	end)

I'm confused to why it's not working at all, help would be appreciated

1 comment

0

Is the Part anchored?

2 answers

✓ Accepted answer

Hello. The problem is that you have a wait(60) in the loop meaning it'll have to wait one minute before going on to the next part, meaning that it would take five minutes for the part to turn invisible. Instead, make a separate loop that makes the EndParts visible again with a wait in between the two loops. Try this:

local Part = script.Parent

local EndParts = {game.Workspace.TEndPart, game.Workspace.DEndPart, game.Workspace.Neon1EndPart, game.Workspace.DessertEndPart, game.Workspace.ASHEndPart}

Part.Touched:Connect(function() 
	for _, object in pairs(EndParts) do 
		object.Transparency = 1 
		object.CanCollide = false 
	end 
	
	wait(60)

	for _, object in pairs(EndParts) do 
		object.Transparency = 0
		object.CanCollide = true
	end 
end) 

If you want it to happen when a humanoid/player touches it, do this:

local Part = script.Parent

local EndParts = {game.Workspace.TEndPart, game.Workspace.DEndPart, game.Workspace.Neon1EndPart, game.Workspace.DessertEndPart, game.Workspace.ASHEndPart}

Part.Touched:Connect(function(otherPart) 
	if otherPart.Parent:FindFirstChildOfClass("Humanoid") then
		for _, object in pairs(EndParts) do 
			object.Transparency = 1 
			object.CanCollide = false 
		end 
		
		wait(60)
	
		for _, object in pairs(EndParts) do 
			object.Transparency = 0
			object.CanCollide = true
		end 
	end
end) 

When the part is touches, it'll check for a humanoid. If it has one, it'll continue the script.

Please accept and upvote this answer if it helped you.

I'm guessing u want it to be on touched, so it would be

Part.Touched:Connect(function(touched)

I'm not sure if it works but give it a go and see what happens, if it not works then i wish u a good day and good luck.

3 comments

0

You don't need a touched parameter for the touched event as it will still work.

0

ty for telling me, i just learned this stuff so sometimes i get something wrong

0

np

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