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

Module code did not return exactly one value???

Here is module script:

CommandFunctions = {}
function CommandFunctions.Speed(Player, Speed)
	Player.Character.Humanoid.Speed = Speed
end
function CommandFunctions.Health(Player, Health)
	Player.Character.Humanoid.MaxHealth = Health
end
function CommandFunctions.Heal(Player)
	Player.Character.Humanoid.Health = Player.Character.MaxHealth
end
function CommandFunctions.God(Player)
	Player.Character.Humanoid.MaxHealth = math.huge
	Player.Character.Humanoid.Health = Player.Character.MaxHealth
end
function CommandFunctions.UnGod(Player)
	Player.Character.Humanoid.MaxHealth = 100
end
function CommandFunctions.RefreshCharacter(Player)
	
end
function CommandFunctions.LoadCharacter(Player)
	Player:LoadCharacter()
end
function CommandFunctions.Kill(Player)
	Player.Character.Humanoid:ChangeState(15)
end
CommandList = {
	{"speed",CommandFunctions.Speed(),{"Player","Number"}}
	,{"health",CommandFunctions.Health(),{"Player","Number"}}
	,{"heal",CommandFunctions.Heal(),{"Player"}}
	,{"god",CommandFunctions.God(),{"Player"}}
	,{"ungod",CommandFunctions.Speed(),{"Player"}}
	,{"re",CommandFunctions.RefreshCharacter(),{"Player"}}
	,{"refresh",CommandFunctions.RefreshCharacter(),{"Player"}}
	,{"respawn",CommandFunctions.LoadCharacter(),{"Player"}}
	,{"kill",CommandFunctions.Kill(),{"Player"}}
}
return CommandList

Here is exact errors:

17:55:47.169 - Module code did not return exactly one value
17:55:47.169 - Requested module experienced an error while loading
17:55:47.169 - Stack Begin
17:55:47.170 - Script 'Workspace.Goon's Admin', Line 2
17:55:47.170 - Stack End

2 comments

0

I think you can only return functions on mudules

0

This is the wrong script.

1 answer

You're returning CommandList instead of CommandFunctions, which you defined at the start of the script. Instead of return CommandList, do return CommandFunctions.

return CommandFunctions --at the end of the script

If you want to access CommandList from other scripts, you can define CommandList as

CommandFunctions.CommandList = {}--insert table here

If this helps, please accept it as the answer!

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