I'm trying to make a hatching pet system but there seems to be an error but on the tutorial that I am watching it it's working perfectly fine
Here is the script
local cost = 500
local PetModule = require(game.ServerScriptService:WaitForChild("PetModule"))
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.leaderstats.Cash.Value >= cost then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 500
local pet = PetModule.chooseRandomPet()
print(pet.Name.." selected")
end
end)

1 comment
your syntax is incorrect, use local cost = 500 local PetModule = require(game.ServerScriptService:WaitForChild("PetModule")) script.Parent.MouseClick:Connect(function(player) if player.leaderstats.Cash.Value >= cost then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 500 local pet = PetModule.chooseRandomPet() print(pet.Name.." selected") end end)