Here's the script ``local cost = 500
local petModule = require(game.ServerScriptService:WaitForChild("PetModule"))
script.Parent.ClickDetector.MouseClick:Connect(function()
if player.leaderstats.Cash.Value >= 500 then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - cost local pet = petModule.chooseRandomPet() print(pet.Name.." selected") game.ReplicatedStorage.HatchEgg:FireClient(player,pet) end
end)
This is because you haven't defined the variable player yet. try putting
script.Parent.ClickDetector.MouseClick:Connect(function(player)