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

expecting Number, got object. How do i fix?

Asked by
DollorLua 235 Moderation Voter
5 years ago

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

0
I'm pretty sure when it sats got object it means it got the module script and not whats inside of it. kittonlover101 201 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
Ad
Log in to vote
0
Answered by
DollorLua 235 Moderation Voter
5 years ago

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

0
Ok! kittonlover101 201 — 5y

Answer this question