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

Could someone fix this transparency script?

I'm trying to make it so that if a player has enough money, and steps on a brick, another brick will appear.

plr = script.Parent.Parent.Parent.Parent.Parent.Parent
price = 0
brick = script.Parent.Parent.Parent["Seasoner - 1200"].Head

 script.Parent.Touched:connect (function() 
	local v = plr.leaderstats.Cash
	if v.Value >= v.Value - price then
		brick.transparency = 0
		else brick.transparency = 1
	end
end)


And for some reason this didn't work.

Edit: This is my new script, but it still doesn't work, what's wrong with this one?

plr = script.Parent.Parent.Parent.Parent.Parent.Parent
price = 0
brick = script.Parent.Parent.Parent["Seasoner - 1200"].Head

 script.Parent.Touched:connect (function() 
	local v = plr.leaderstats.Cash
	if  v.Value - price >= 0 then
	brick.Transparency = 0
	else brick.Transparency = 1
	end
end)


2 comments

1

It's pretty clear. It's .Touched, not .onTouch

0

You forgot to capitalize the 'T''s in 'transparency' [brick.Transparency = 0].

1 answer

Indentation-wise, else should be on the same level as its if.

Your conditional:

v.Value >= v.Value - price

Always evaluates to true, since the value minus the price will always be less than the value alone.

Try using this conditional instead:

v.Value - price >= 0

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