Image labels on a surface gui not fading away after a proximity prompt has finished

I’m attempting to make dirt stains on a surface gui fade away after a prompt has finished being held

the issue is that even though the first line of code has moved the object to where it is supposed to be, the second part of the code containing the image fade never runs and I know this because “fade” hasn’t been printed into the console. (no errors have shown up in console as well)

I am stuck and don’t know what is causing this behaviour

local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("CluePaperFloor2Stage2")
local proximityPrompt = script.Parent.ProximityPrompt
local Sink = game.Workspace.Prompts.SinkClean
local PaperDirty = script.Parent.PaperDirty
local parts = PaperDirty.SurfaceGui.PaperDirtyStage2Floor2Clue.ImageLabel.Folder:GetChildren()
PaperDirty.Position = Vector3.new(-295.119, -5.823, -589.318)


proximityPrompt.PromptButtonHoldEnded:Connect(function(player)
	proximityPrompt.Triggered:Connect(function(player)
		
		PaperDirty.Position = Vector3.new(-295.119, 2.823, -589.318)
		for i , v in pairs(parts) do
			while v.ImageTransparency > 0 do
				v.ImageTransparency += 0.05 -- The greater this number, the less it takes to fade item
				wait(0.1) -- The the lower the number in wait(), the less time it takes to fade item
				print("fade")
			end
			if v.ImageTransparency > 1 then
				v.Visible = false
				print(false)
			end
		end
	end)
end)
local parts = PaperDirty.SurfaceGui.PaperDirtyStage2Floor2Clue.ImageLabel.Folder:GetChildren()

This line right here, your already getting the children of it, but what if they haven’t been loaded in yet?

Instead, change your script to this:

local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("CluePaperFloor2Stage2")
local proximityPrompt = script.Parent.ProximityPrompt
local Sink = game.Workspace.Prompts.SinkClean
local PaperDirty = script.Parent.PaperDirty
local parts = PaperDirty.SurfaceGui.PaperDirtyStage2Floor2Clue.ImageLabel.Folder
PaperDirty.Position = Vector3.new(-295.119, -5.823, -589.318)


proximityPrompt.PromptButtonHoldEnded:Connect(function(player)
	proximityPrompt.Triggered:Connect(function(player)

		PaperDirty.Position = Vector3.new(-295.119, 2.823, -589.318)
		for i , v in pairs(parts:GetChildren()) do
			while v.ImageTransparency > 0 do
				v.ImageTransparency += 0.05 -- The greater this number, the less it takes to fade item
				wait(0.1) -- The the lower the number in wait(), the less time it takes to fade item
				print("fade")
			end
			if v.ImageTransparency > 1 then
				v.Visible = false
				print(false)
			end
		end
	end)
end)

Just put that in and unfortunately It still isn’t functioning, its the exact same thing as last time the paper object changes position but the transparency fade never runs :sweat:

Can I see a layout of your workspace? Just want to see if you actually have children in the folder.

Sure, here’s a screenshot of it

I think these 2 are incorrect?
image
image

Might need to swap them.

I just swapped the code still the same issue

Try using :WaitForChild(), also can I see your outputs real quick, and does it even print “false”?

I just found the issue I put v.ImageTransparency > 0 when it should be v.ImageTransparency > 1, that’s my fault sorry for wasting your time thanks for the help though.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.