A model doesn't disappear after triggering a ProximityPrompt

I wanted to make that if you trigger the proximity prompt the model will disappear,but for some reason it doesn’t disappear without an error,how can i fix it?

local ProximityService = game:GetService("ProximityPromptService")
local Proximity = script.Parent:WaitForChild("ProximityPrompt")
local GasterSound = script.Parent:WaitForChild("Gaster")
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
	2,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.InOut,
	0,
	false,
	0	
)
local Goals = {
    Transparency = 1
}

Proximity.Triggered:Connect(function()
	GasterSound:Play()
	for i, part in pairs(script.Parent.Parent:GetChildren()) do
		if part.ClassName == part then
			TweenService:Create(part,Info,Goals)
		end
	end
end)

Would really appreciate any help

1 Like

Looks like you’re forgetting to play the tween it’s self, just add :Play() at the end of the statement inside of the loop

should look like this

TweenService:Create(part,Info,Goals):Play()

Also, the conditional won’t do anything because you’re comparing a string to an instance, like post mentioned below

2 Likes

Doing: if part.ClassName == part then will do nothing since you are attempting to compare ClassName with an instance… I recommend doing this:

if part:IsA("BasePart") then 

A BasePart can be any physical part for ex: Part, MeshPart, Union, etc.

3 Likes