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

expecting Number, got object. How do i fix?

im sending numbers i get from a module script to a normal script via a local script sending it. I get this: ServerScriptService.SwordHitScript:3: bad argument #1 to 'random' (number expected, got Object) on this: local Damage = math.random(min, max) the local script proves it wrong with a print that prints both the min and the max

print(min)
print(max)

and it prints 1 and 2. those are numbers right? last I recalled a number isn't a object oh and heres min and max in the module script

local Module = {
    --] Basic Configuration
    ["MaxDamage"] = 2,
    ["MinDamage"] = 1,
    ["Cooldown"] = 1,
    ["Cost"] = 0,
    --] Advanced
    ["HumanoidToKill"] = "Enemy"
}

return Module

and in the local script heres the define of min and max

local min = _M.MinDamage
local max = _M.MaxDamage

and here is the module

local _M = require(script.Parent.Settings)

please help someone

1 comment

0

I'm pretty sure when it sats got object it means it got the module script and not whats inside of it.

2 answers

✓ Accepted answer

Here is the method I use.

Don't know if it'll work for what you're doing, but worth a try.

This DID work for me by the way.

Also make sure if your module script is in replicated storage that your script isn't in there too.

I don't think the script will work if so.

Module:

local module = {}

	--] Basic Configuration
	module.MaxDamage = 2;
	module.MinDamage = 1;
	module.Cooldown = 1;
	module.Cost = 0;
	--] Advanced
	module.HumanoidToKill = "Enemy"
 
return module

Script:

local _M = require(script.Parent.Settings)

local min = _M.MinDamage
local max = _M.MaxDamage

print(min)
print(max)

I have fixed the issue. Thank-you for your answer but i found my mistake.

1 comment

0

Ok!

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