Im Currently Trying to Achieve Alvin Blox’s Pet Hatching Tutorial But Im Having an Error on the Click Detector Script.
Im Having an Error Whenever I join the game and press the Click Detector. It takes Cash from the player, But in the output it’s supposed to say The Name of the Pet Then Selected so say I have a dog it would be “Dog Selected” The Error says " Workspace.Model.Text.Script:11: attempt to call a nil value"
Some Solutions I have tried are Rewriting The Code Multiple Times, Looking Up The error, and So Fra None of These have worked.
Below Is the Code, I Also will have the Video Linked, Any Feedback, or Help Would Be Amazing!
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 - cost
local pet = petModule.chooseRandomPet()
print(pet.Name.." selected")
end
end)
Thank You For Any Help!