Humanoid is not a valid member of model?

Yes ranp1 is an actual random generated person name.

Is this a local or server script?

It is a server script, yeah…

Could we take a look at how hammertable is being generated and what it contains? I believe the problem might be with that.

just remove all your timeouts so you can see where it actually breaks. you are silently catching errors, its horrible :frowning:

you can add them back when you know your controlled conditions work properly

game.ReplicatedStorage.Hammers.Event:Connect(function(plrtable)
	hammerevent = true
	hammertable = plrtable
	for i,v in pairs(hammertable) do
		print(v)
	end
end)
local amount = 3
local players = {}
function hi(x)
	if amount > 0 then
	amount = amount - 1
	local y = x.Backpack
	local z = game.Lighting["Hammer"] 
	z:Clone().Parent = y  
	table.insert(players, x.Name)
	if amount == 0 then
		game.ReplicatedStorage.Hammers:Fire(players)
	end
	local char = x.Character
	end
end

script.Parent.ClickDetector.MouseClick:Connect(hi)

2 seperate scripts.

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.