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

How come the it still buys the thing when i dont have enough?

i have a code and i need to know why it works when i don't have enough money

local tycoon = script.Parent.Parent.Parent local tycoonOwner = tycoon.TycoonOwner local button = script.Parent local container = button.Parent local purchasedItem = container.PurchasedItem local cost = container.Cost.Value

local itemClone = purchasedItem:Clone() purchasedItem:Destroy()

local function getPlayerFromPart(part) local character = part.Parent

if character then
	local player = game.Players:GetPlayerFromCharacter(character)
	itemClone.Parent = container
	return player
end

end local function attemptToBuy(player) local money = player.leaderstats.Funds

if money.Value >= cost then
	money.Value = money.Value - cost

	itemClone.Parent = container
	button:Destroy()
		
end

end local function onTouched(otherPart) local player = getPlayerFromPart(otherPart) if player then if tycoonOwner.Value then attemptToBuy(player) end end end

button.Touched:Connect(onTouched)

1 comment

0

put all of your code in a code block

1 answer

✓ Accepted answer

This should work

cost = 500 -- the price you want

cost.Value = cost.Value - money.Value

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