ClickDetector.Script:17: attempt to perform arithmetic (sub) on function
local clickDetector = script.Parent
local RepllicatedStorage = game:GetService(("ReplicatedStorage"))
local DataModule = require(RepllicatedStorage:WaitForChild("DataModule"))
local Pets = RepllicatedStorage:WaitForChild("Pets")
local function ChoosePet (player)
local PlayerGui = player:WaitForChild("PlayerGui")
local MainGui = PlayerGui.MainGui
local EggIcon = MainGui.EggIcon
local PetImages = MainGui.PetImages
local timer = tick()
EggIcon.Visible = true
while os.time - timer < DataModule.EggOpeningLength do
wait(.1)
EggIcon.Rotation = math.random(-9,9)
end
local petNumber = math.random(1,100)
local petFound = false
local pet = nil
while petFound == false do
for i, v in pairs(DataModule.Pets) do
if math.random(1,v) == petNumber then
petFound = true
pet = i
end
end
end
EggIcon.Visible = false
local PetImage = PetImages:FindFirstChild(pet)
PetImage.Visible = true
wait(2)
PetImage.Visible = false
return pet
end
clickDetector.MouseClick:Connect(function(player)
if player.leaderstats.Cash.Value >= DataModule.EggCost then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - DataModule.EggCost
local petOpened = ChoosePet(player)
print(petOpened)
local pet = Pets:FindFistChild(petOpened):Clone()
pet.Position = player.Character.HumanoidRootPart.Position
pet.Parent = game.Workspace
end
end)