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

ServerScriptService.ShopModule:9: attempt to index field 'OreMaterial' (a nil value)?

Asked by 4 years ago
Edited 4 years ago

This question has been solved by the original poster.

This is the module Script

function Shop.Sell(player)
    local Ore = Shop.OreName
    if player.OreMaterial[Ore].Value >= OreMod[Ore].price then
        player.leaderstats.Money.Value = player.leaderstats.Money.Value * OreMod[Ore].price
        player.OreMaterial[Ore].Value = 0
    else
        print("Nothing to sell")
    end
end

I get an error: 15:47:35.845 - ServerScriptService.ShopModule:9: attempt to index field 'OreMaterial' (a nil value) if player.OreMaterial[Ore].Value >= OreMod[Ore].price then is the part I need fixed

This is inside the LocalScript

local player = game:GetService("Players")

function SellStone()
    game.ReplicatedStorage.LevelUp:FireServer( "Stone")
end

script.Parent.SellStone.MouseButton1Click:Connect(SellStone)

and this is the script where I access my RemoteEvents

function SellOre(player, Ore)
    ShopMod.OreName = Ore
    ShopMod:Sell(player)
end

0
Your Module script from line 5 to 6, I have a question. Why do you want to make the player's money value * Ore's price then replace player's money value become 0? I confused about this and took it was the error occured reason xD Xapelize 2658 — 4y
0
Just ignore that part atm, I need help with the if player.OreMaterial[Ore].Value >= OreMod[Ore].price then BosOfroblox 40 — 4y
0
the player table does not have OreMaterial in it. Overscores 381 — 4y
0
I Know, but it's fixed now. BosOfroblox 40 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

It's been fixed, everything works now.

Ad

Answer this question