Attempt to index number with 'Transparency'

So im trying to create a tile, that fades out then gets destroyed. I created this block of code:

local tile = script.Parent

tile.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		repeat 
			tile = tile.Transparency + 0.1
			task.wait(0.1)
		until
		tile.Transparency == 1
		tile:Destroy()
	end
end)


However when im trying to use it i get this error:
''attempt to index number with ‘Transparency’"
Does someone know how to fix this? because im stuck :sweat_smile:

1 Like

You’re changing the tile variable to a number

What should i change to make it work? i really dont get it im sorry

You’re supposed to do

tile.Transparency = tile.Transparency + 0.1

or

tile.Transparency += 0.1
1 Like

:man_facepalming: Thanks anyway for helping

(Char limit)

the reason for your error is because you did

tile = tile.Transparency +0.1

when you needed to do

tile.Transparency = tile.Transparency + 0.1

or

tile.Transparency += 0.1

whoops didnt realise it was alr solved

1 Like