#Unable to cast value to Object - Line 8

1 messages · Page 1 of 1 (latest)

echo axle
#

I'm trying to spawn a cow when I click the button. But I get an error.


print("Shop Script Loaded") 

local buyButton = game.Workspace.Sign.Button
buyButton.Parent = workspace
buyButton.ClickDetector.MouseClick:Connect(function(player)
    local player = game.Players:GetPlayerFromCharacter("Player", player.UserId)
    if player == nil then return end 
    local dataStore = DataStoreModule.find(player)
    if dataStore == nil then return end
    if dataStore.State ~= true then return end
    if dataStore.Value.Coins >= 1000 then
        dataStore.Value.Coins -= 1000
        dataStore.Leaderstats.Coins.Value = dataStore.Value.Coins
        local cow = game.ReplicatedStorage.cow:Clone()
        cow.Parent = workspace


        print("Enough Money")
    else
        print("Not enough money")
        dataStore.Value.Coins += 10000
        dataStore.Leaderstats.Coins.Value = dataStore.Value.Coins

    end

end)```
bleak tangle
#

what is the error?

finite monolith
echo axle