Humanoid is not a valid member of model?

I have had bad experience with math.random. It generates the same number again and again sometimes for me.

I think the problem lies when I getranplayer() because it gets the person there.

if you use the same seed and restart it each time, that happens

its an equation that cycles through numbers not actually random
seeding with tick() is popular

Can we continue this in PMs? This post is getting unnecessarily long.

Yes, but I donā€™t think that it is a random error. It is giving me the players names back fine.

@ShutokouBattle

ā€¦what? I donā€™t see how math.random() is easier to use than the Random object. Thatā€™s not even the source of OPā€™s error. This is a fairly pointless suggestion. In addition: if Random fails to get a indice from a table, I donā€™t see how switching methods would change results.

Posts from the object's author if you're interested in learning about the object. Something you should be searching before making unsubstantiated assertions.

A Random Feature
Random:NextInteger() help? - #16 by Fractality_alt
Weighted crate system not choosing an item of the same rarity as another - #8 by colbert2677


@Pharyx_Styx

Not required with the Random object. It pulls a seed from an internal entropy source. A seed is typically for if you need predictable results - you can pass one seed at one moment and the same seed at another moment.


Honest best guess is that thereā€™s a model named the same as a player. How are entries inserted into hammertable? Have you gone over each line of code and debugged it to find a potential source of error?

Interesting, I have never used the Random object before. Just default to math for mathy things. Iā€™ll have to look into that.

Thanks again for all the nifty info :slight_smile: This seems to be happening regularly, so much to learn.

This shouldnā€™t happen. Unless you are using something like math.random(1,2) then you shouldnā€™t get the same numbers repeatedly.

I used math.random() for my random npc spawns and they spawned all in the same place. I repeated the math.random() for every npc.

The fact that they can spawn in the same place may have been the problem.

You may have been using math.random wrong. I use math.random a lot and I have never gotten the same result over and over again.

for i = 1, 100 do local spawn = math.random(1, 100)  end

What is wrong with that?

You would have to spawn then NPC in that loop, or else spawn would equal the last math.random

I did, im just getting the math.random

Yeah, I did not make it a variable.