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

Im trying to get this model to disappear when you touch a brick?

How do you make a model disappear on the touch of a brick? This is what I have.

waittime = 5 -- Time Between each hit
amnt = 1 --how much you get for it
function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if (h~=nil) then
		local thisplr = game.Players:findFirstChild(h.Parent.Name)
		if (thisplr~=nil) then
			local stats = thisplr:findFirstChild("leaderstats")
			if (stats~=nil) then
				local score = stats:findFirstChild("Points")
				if (score~=nil) then
					score.Value = score.Value + amnt
				end
			end
		end
		
		game.Workspace.Mod.Transparency = 1
		game.Workspace.Mod.Disabled = true
		wait(waittime)
		game.Workspace.Mod.Transparency = 0
		game.Workspace.Mod.Disabled = false		


	end
end

script.Parent.Touched:connect(onTouched)

1 answer

local debounce = false

script.Parent.Touched:connect(function(hit)
	if hit ~= nil and hit.Parent:FindFirstChild("Humanoid") then
		if not debounce then
			for i,v in pairs(game.Workspace.Mod:GetChildren()) do
				if v:IsA("Model") then
					v.Transparency = 1 --Makes part in model invisible
					v.CanCollide = false --Turns off collision for the part
				end
			end

			debounce = true

			wait(5)

			for i,v in pairs(game.Workspace.Mod:GetChildren()) do
				if v:IsA("Model") then
					v.Transparency =  0 --Makes part in model visible again
					v.CanCollide = true --Turns on collision for the part again
				end
			end

			debounce = false
		end
	end
end)

The script I have provided above should theoretically work. I have not tested any of it at all.

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