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

Attempt to index nil with transparency???

WHY DUS THIS HAPEN TO MEEEEEEEE forget the rest of the song Anyways

Im getting the error "Attempt to index nil with 'transparency' " and it makes no sense to me Its not like I can use wait for child for a parent makes no sense

script:

script.Parent.Touched:Connect(function(hit)
	local character = hit.Parent
	if character:FindFirstChild('Humanoid') then
		local player = game.Players:GetPlayerFromCharacter(character)
		script.Parent.Transparency = 1
		script.Parent.CanCollide = false
		script.Disabled = true
		player:WaitForChild('leaderstats'):WaitForChild('DollarsToCollect').Value = player.leaderstats.DollarsToCollect.Value + 1
		wait(20)
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
		script.Disabled = false
	end
end)

Wait! Something else that should be noted it works the first time, but not the second, it becomes invisible, but not visible again

5 comments

0

Have you anchored the part? If you haven't then the part will obviously fall down to the abyss.

0

I'VE MADE MY MISTAKES~~

0

GOT NOWHERE TO RUN~~

0

THE NIGHT GOES ON~~

0

y e s

1 answer

✓ Accepted answer

The reason you get the error Attempt to index nil with transparency on script.Parent.Transparency even though it worked before is because you have it unachored (part is Anchored = false) and when you do script.Parent.CanCollide = false so it falls into the void and things that fall into the void get auto destroyed, so the reference it once held before to the part now has become nil due to the part being destroyed. set anchored = true before you make it cancollide false and it will work

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