#I NEED HELP pt2

1 messages · Page 1 of 1 (latest)

floral summit
#

i have this problem:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Plot = workspace:WaitForChild("PLOT")
local Player = game.Players.LocalPlayer
local leaderstats = Player:FindFirstChild("leaderstats")
local Cash = leaderstats.Cash

local CatsHandler = {}

function CatsHandler:GetCatToPlot(Cat)
local CatClone = Cat:Clone()

CatClone.Position = Plot.Position + Vector3.new(0, 0, 0)
CatClone.Parent = workspace.Cats

end

function CatsHandler:PurchaseCat(Cat, Cost)
if not leaderstats then return end

if Cash.Value >= Cost then
    Cash.Value -= Cost
    local BoughtCat = ReplicatedStorage.Assets.Cats:FindFirstChild(Cat)
    CatsHandler:GetCatToPlot(BoughtCat)
else
    warn("Player cant afford this cat!")
    return
end

end

return CatsHandler
this dosnt do anything

azure panther
#

What excatly doesnt do anythings?

floral summit
#

i have a gui buttoins with a local script that runs the purchasecat functoin but it dooesnt do anything when the buttons is pressed

azure panther
#

I would just do debugs then, it might be that they end at if not leaderstats then return end

Just put print("Debug 1")
and so going on, like in every if else, and then you can see where it does stop. like which number didn't it said "debug"

desert lantern
#

:GetCatToPlot and :PurchaseCat are not built-in functions

azure prairie
#

this looks a bit like object oriented programming

#

Try searching roblox oop tutorial

umbral elm
#

make sure ur setting leaderstats first

umbral elm
floral summit
#

module

umbral elm
#

r u requiring it

floral summit
#

yes

umbral elm
#

do u call the functions properly

umbral elm
# floral summit yes

try at the beginning of purchasecat function printing everything ur script needs

#

best way to debug

floral summit
#

how should i do that

desert lantern
#

dude :GetCatToPlot is not a valid function

umbral elm
umbral elm
#

before the return statement

#

ur leaderstats might just not get fetched properly

floral summit
#

like this: local function PurchaseCat(Cat, Cost)
if Cash.Value >= Cost then
Cash.Value -= Cost
local BoughtCat = ReplicatedStorage.Assets.Cats:FindFirstChild(Cat)
CatsHandler:GetCatToPlot(BoughtCat)
else
warn("Player cant afford this cat!")
print(Cat,Cost,leaderstats)
return
end
end

umbral elm
#

use WaitForChild("leaderstats",2)

#

no use ur original module script

#

and at the beginning of the PurchaseCat function print ur values