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

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

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 ?

2 comments

0

Be more specific, and put all your code in a code block and tab it correctly.

0

It is very possible, but this is a free-model script. You must attempt to do things yourself and request assistance.

1 answer

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)

4 comments

0

doesnt work

0

pls someone answer correctly cuz when i buy a model and theres another model in that which one i bought it doesnt work...

0

Well for the script to work on its own you have to customize the location of the

0

Model and button

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