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

Is it possible to make tycoon button remove models but not buy ?

Asked by
Bulvyte 388 Moderation Voter
10 years ago

Heya i wanted to know can you help me make the tycoon button remove script: When you touch the tycoon buy button the model comes thats ok But i want to make another button like when you touch the buy button the model doesn't come but it removes it so i want to remove unwanted parts when buildin stuff heres the script

-------------------------------------------------------------------------------------------------------------------------
model = script.Parent.Parent.Parent.MailboxA
Upgradecost = 100
MoreCash = 10
-------------------------------------------------------------------------------------------------------------------------
upgradeStuff = model:clone()
upgrad = script.Parent.Parent.Parent.Upgrad

wait(0)

model:remove()
owner = script.Parent.Parent.Parent.OwnerName 
local ting = 0
trans = {}

function onTouched(hit)
    if ting == 0 then
    ting = 1
    check = hit.Parent:FindFirstChild("Humanoid")

    if check ~= nil then
    if hit.Parent.Name == owner.Value then
        local user = game.Players:GetPlayerFromCharacter(hit.Parent)
        local stats = user:findFirstChild("leaderstats")

        if stats ~= nil then
            local cash = stats:findFirstChild("Cash")
            if cash.Value > (Upgradecost-1) then

                cash.Value = cash.Value - Upgradecost
                                upgrad.Value = upgrad.Value + MoreCash
                upgradeStuff.Parent = script.Parent.Parent.Parent
                UPparts = upgradeStuff:GetChildren()
                for i = 1, #UPparts do
                    if UPparts[i]:IsA("BasePart") or UPparts[i]:IsA("Seat") then
                        table.insert(trans,UPparts[i].Transparency)
                        UPparts[i].Transparency = 1
                    end
                end
                script.Parent.Parent.Name = "Building..." -- change this name to what it gonna say when it build your model!
                for i = 1, #UPparts do
                    if UPparts[i]:IsA("BasePart") or UPparts[i]:IsA("Seat") then
                        repeat
                        wait()
                        UPparts[i].Transparency = UPparts[i].Transparency -0.05
                        until UPparts[i].Transparency <= trans[i]
                        UPparts[i].Transparency = trans[i]
                    end
                end
                script.Parent.Parent:remove()
            else
            oldname = script.Parent.Parent.Name
            script.Parent.Parent.Name = "You need "..Upgradecost -cash.Value.."$ more to buy this"
            wait(4)
            script.Parent.Parent.Name = oldname
            end
        end
    end
    end

    ting = 0
    end
end

script.Parent.Touched:connect(onTouched)

So is it possible to make that or not ?

0
Be more specific, and put all your code in a code block and tab it correctly. Perci1 4988 — 10y
0
It is very possible, but this is a free-model script. You must attempt to do things yourself and request assistance. Necrorave 560 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Yeah it's possible to make a tycoon button remove a model.

local Button = script.Parent
local Model = script.Parent.Parent["ModelNameHere"]
local Cost = 0
local MoneyType = "Cash"

Button.Touched:connect(function(Hit)
if Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:FindFirstChild(Hit.Name)
if Player and Player:FindFirstChild("leaderstats") and Player.leaderstats:FindFirstChild(MoneyType) then
local Stats = Player.leaderstats[MoneyType]
if Stats.Value - Cost > 1 then
Stats.Value = Stats.Value - Cost
Model:Destroy()
Button.Transparency = 1
end
end
end
end)
0
doesnt work Bulvyte 388 — 10y
0
pls someone answer correctly cuz when i buy a model and theres another model in that which one i bought it doesnt work... Bulvyte 388 — 10y
0
Well for the script to work on its own you have to customize the location of the xImmortalChaos 565 — 10y
0
Model and button xImmortalChaos 565 — 10y
Ad

Answer this question