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

"chicken is not a valid member of StarterPack" error in module script?

I have a module script in ReplicatedStorage and a script in a tool. In the module script I have a function w. 3 parameters, the values of which are set in the script. For some reason, I used one of the parameters in the module script, and it errored, saying "chicken is not a valid member of StarterPack" in the module script.

MODULE SCRIPT:

local module = {}

local player = game.Players.LocalPlayer
local leaderstats = player.leaderstats
module.giveChickenEaten = function(chicken, chickenIntValue, biteAmount)
	print("Calculating chicken eaten...")
	leaderstats["Chicken Eaten"].Value = leaderstats["Chicken Eaten"].Value + game.StarterPack.chicken.chickenIntValue.Value --chikcen is not a valid member of StarterPack
	biteAmount.Value = biteAmount.Value - 1
	if biteAmount.Value == 0 then
		chicken:Destroy()
	end
end

return module

SCRIPT:

local module1 = require(game.ReplicatedStorage.ModuleScript) --where the module script is activated
	module1.giveChickenEaten(script.Parent, script.Parent.coldFriedChickenValue.Value, script.Parent.biteAmount.Value)

--(this is activated inside a function)

Thanks!

1 answer

✓ Accepted answer

Put this after line 5:

game.StarterPack:WaitForChild("chicken")

Or, maybe there is nothing called "chicken" in the starterpack. Are you sure it's the starterpack and not the specific startergear of the player?

3 comments

0

There's nothing called chicken, it was just the parameter

0

If there is nothing called "chicken" in the StarterPack, then you can't index it. If it's the parameter, it acts like a variable. Does removing "game.StarterPack" in line 7 help?

0

Thanks! I just had to remove all the ".value" parts. The biteAmount part still won't work, though (I deleted the .Value).

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