Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Could someone fix this transparency script?

Asked by 9 years ago

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)


1
It's pretty clear. It's .Touched, not .onTouch Tkdriverx 514 — 9y
0
You forgot to capitalize the 'T''s in 'transparency' [brick.Transparency = 0]. TheeDeathCaster 2368 — 9y

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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
Ad

Answer this question