I am currently testing my module script at the moment. I am trying to get a simple pet system down. The problem is, is that it says I dont have enough money for the egg, but it still equips it. (or just parents to the workspace for now)
local TweenService = game:GetService('TweenService')
local petModels = game:GetService('ReplicatedStorage'):WaitForChild('Pets')
local petsListModule = require(script.Parent.PetsList)
local module = {}
function module.HatchEgg(plr, cost)
if plr.leaderstats.Money.Value >= cost then
return true
else
return false
end
end
function module.EquipPet(plr, pet)
local petModel = petModels[pet]:Clone()
if petModel then
petModel.Parent = workspace
end
end
function module.SetupEgg(eggName)
local eggModel = eggName:FindFirstChild('Mesh')
local cost = eggModel:WaitForChild('Cost').Value
local proximtyPrompt = Instance.new('ProximityPrompt')
proximtyPrompt.Name = 'Prompt'
proximtyPrompt.HoldDuration = 0.2
proximtyPrompt.ObjectText = "$".. tostring(cost)
proximtyPrompt.ActionText = 'Hatch'
proximtyPrompt.Parent = eggModel
proximtyPrompt.Triggered:Connect(function(plr)
module.HatchEgg(plr, cost)
wait(2)
local result = module.EquipPet(plr, petsListModule.WaterEgg.Monster)
if result == true then
module.EquipPet(plr, petsListModule.WaterEgg.Monster)
else
print("[Module] - Cant equip because you have no money!")
end
end)
return proximtyPrompt
end
return module