If "Remove" touches "Bottom" then remove turns transparent and cancollide off

@LucasTutoriaisSaimo
I’m trying to achieve something like this…

When the part named “Removed” touches “Bottom” then “Removed” becomes transparent and non-collidable.

This is exactly what I put to try to achieve this, it didn’t work.

function OnTouch(hit)

	game.Workspace.Remove.Transparency = 1
	game.Workspace.Remove.CanCollide = false


end

game.Workspace.Bottom.Touched:connect(OnTouch)

if game.Workspace.Remove.CanCollide ~= false then ?

1 Like

maybe something like

local removed = 
local bottom = 
Bottom.Touched:Connect(function(touched)
	If touched == removed then
		removed.Transparency = 1
		removed.CanCollide = false
	end
end)

edit: But then wouldnt removed fall into the void? Wouldnt you benefit a bit more from doing removed:Destroy()?

2 Likes

Okay, i’ll try that. Do I put the script in “Bottom” or “removed” or?

removed:Destroy() would be nice

If you’re trying to check if the Part’s name is equal to what you wanna find, then…

function OnTouch(hit)
    if hit.Name == "Bottom" then
    	game.Workspace.Remove.Transparency = 1
	    game.Workspace.Remove.CanCollide = false
    end
end

game.Workspace.Bottom.Touched:connect(OnTouch)

Just add a simple if statement to check

1 Like

Will you have multiple parts named removed?

1 Like

Yeah. @JackscarIitt I don’t want that so if anything touches “Bottom” to get removed.

local Bottom
Bottom.Touched:Connect(function(touched)
	If touched.Name == "removed" then
		touched:Remove()
	end
end)

this would make it so that any block that touches “Bottom” and is named “removed” will get destroyed

1 Like

Alright. But where do I put the script? And what type of script is it?

Server script, and serverscriptservice, set Bottom to your part, Bottom or put it in Bottom and set the variable to be script.Parent

1 Like

Didn’t work for some reason. I put the script in bottom and did

local Bottom == script.Parent

Heres an image.

local Bottom = script.Parent
Bottom.Touched:Connect(function(touched)
	if touched.Name == "Removed" then
	touched:Remove()
end
end)
--In ServerScriptService
local Bottom = workspace.Bottom

Bottom.Touched:Connect(function(touched)
	if touched.Name == "Removed" then
	    touched:Remove()
    end
end)

Do make sure to parent where your Bottom part is

1 Like
local Bottom = script.Parent -- Choose
Bottom.Touched:Connect(function(touched)
	if string.lower(touched.Name) == string.lower("Removed") then
        local Target = touched -- If you want a whole model to destroy then just change to where the model is, example: touched.Parent
		Target:Remove() 
	end
end)
2 Likes

Thank you so much everyone! It worked! :grin: