Problem with generating random levels/values to npcs

Hello, i am making a taming system, like the system in ark but i have a very basic problem that i dont know how to fix. I generate a random number to a intvalue. The random number is the level for the npc. i display it on a billboard gui with a textlabel and it is working perfectly. But when i copy and paste more of the Dummys/npcs They get the same value/ level. Not so random like i want it.

script 1:

local character = script.Parent

local Humanoid = character:WaitForChild(“DinoHumanoid”)

local function generatenumber()

return math.random(1,40)

end

local Level = Instance.new(“IntValue”)

Level.Name = “Level”

Level.Parent = character

Level.Value = generatenumber()

Script 2:
local character =
script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Dummy

script.Parent.Text = "Level: "…character:WaitForChild(“Level”).Value

1 Like

Instead of doing generatenumber() try doing HttpService:GenerateGUID(true)

But you would have to add local HttpService = game:GetService(“HttpService”)

You also have to enable Access to HttpServices in your Game Settings.

1 Like

Are you sure that the character variable is assigned correctly here? Just in case, try printing out the character variable to make sure that it is the correct NPC. If the character variable is assigned correctly and the character:WaitForChild("Level").Value is the correct value, then you might need to consider alternatives to using math.random().

1 Like