Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

4 comments

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

0

Just ignore that part atm, I need help with the if player.OreMaterial[Ore].Value >= OreMod[Ore].price then

0

the player table does not have OreMaterial in it.

0

I Know, but it's fixed now.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.