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

How do I make my tycoon accept bricks in a certain color?

Asked by 10 years ago

I'm currently working on a tycoon and was wondering how I could make my tycoon money-getter accept a brick of a certain color. Right now I have the money-getter accept bricks by their name.

money = script.Parent.Parent.Money

function onTouched(hit)
    if hit.Name == "TycoonBrick1" then
    hit:remove()
    money.Value = money.Value + 50
    elseif hit.Name == "TycoonBrick2" then
    hit:remove()
    money.Value = money.Value + 100
    end
end

script.Parent.Touched:connect(onTouched)

I've tried codes such as...

money = script.Parent.Parent.Money

function onTouched(hit)
    if hit.BrickColor == "Bright blue" then
    hit:remove()
    money.Value = money.Value + 50
    elseif hit.BrickColor "Bright red" then
    hit:remove()
    money.Value = money.Value + 100
    end
end

script.Parent.Touched:connect(onTouched)
money = script.Parent.Parent.Money

function onTouched(part)
    if part.BrickColor == "Bright blue" then
    part:remove()
    money.Value = money.Value + 50
    elseif part.BrickColor "Bright red" then
    part:remove()
    money.Value = money.Value + 100
    end
end

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by
istiyak 13
10 years ago

I think the problem is that you haven't mentioned anything about leaderstats , unless your script understands what you are talking about.

or try something like

FindFirstPlayer.leaderstats.money.Value + 100

i dont want to give you the whole script

0
My leaderstats is "Cash" and my collect is "Money". The money collected goes in to cash when I use brick names. Beyazidalt 0 — 10y
0
i edited the script istiyak 13 — 10y
0
And where would I put that line of code? Beyazidalt 0 — 10y
0
You have to figure out yourself or just put it where it says money.value = money.value + 100 istiyak 13 — 10y
0
Doesn't work. Beyazidalt 0 — 10y
Ad

Answer this question