Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

It says "Unknown Global 'player'"?

Asked by 3 years ago

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)

1 answer

Log in to vote
0
Answered by
kjljixx 42
3 years ago

This is because you haven't defined the variable player yet. try putting

script.Parent.ClickDetector.MouseClick:Connect(function(player)
Ad

Answer this question