Error when ProximityPrompt triggered


It’s giving that error when ProximityPrompt is triggered.
Here is the script :

local ProximityPrompt = script.Parent

ProximityPrompt.Triggered:Connect(function(player)
	for i = 1,100 do
		player:WaitForChild("PlayerGui"):WaitForChild("ScreenRat").Frame -= 0.01
		task.wait(0.02)
	end


end)

You can tell by the script what I want to do.
I haven’t found anything to fix that , does anybody knows.

You subtracting 0.01 by a frame, are you trying to change its properties in the for loop?

Actually it’s more like when ProximityPrompt is triggered. A frame is fading but reverse.

So edit its backgroundTransparency property

local ProximityPrompt = script.Parent

ProximityPrompt.Triggered:Connect(function(player)
	for i = 1,0,0.1 do
		player:WaitForChild("PlayerGui"):WaitForChild("ScreenRat").Frame.BackgroundTransparency -= i
		task.wait(0.02)
	end
end)

With a start value of 1, an end value of 0 and a step value of 0.1 the numeric for loop will never end. A step value of -0.1 should be used instead. The WaitForChild calls are also unnecessary.

local Prompt = script.Parent

Prompt.Triggered:Connect(function(Player)
	for i = 1, 0, -0.1 do
		Player.PlayerGui.ScreenRat.Frame.BackgroundTransparency = i
		task.wait(0.05)
	end
end)
1 Like