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

LUA: attempt to compare userdata with number how i fix it?

Asked by
Ez3cHD 0
4 years ago
Edited 4 years ago

i need fix "attempt to compare userdata with Number"


if script then

--Script local tycoon = script.Parent.Parent.Parent local button = script.Parent local container = button.Parent local purchasedItem = script.Parent.Parent.PurchasedItem local cost = container.Cost local tycoonOwner = tycoon.TycoonOwner local itemClone = script.Parent.Parent.PurchasedItem:Clone() purchasedItem:Destroy() local function getPlayerFromPart(part) local character = part.Parent

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

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

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

   itemClone.Parent = container
   button:Destroy()    
end   

end end local function onTouched(otherPart) local player = getPlayerFromPart(otherPart)

if player then
   if tycoonOwner.Value == player then
    attemptToBuy(player)                         <--- "Fix"
    end
end

end button.Touched:Connect(onTouched) --Script

end

0
cost is a userdata, use cost.Value when comparing to money.Value DeceptiveCaster 3761 — 4y

Answer this question