How do I make a model appear for a specific person with a random possibility?

I want to make a model that has a 1 in 100,000 chance of appearing randomly to someone only and not the entire server (I already have a specific place in the game for the model to appear if they do get the 1/100,00 chance), I want to make it so that once the player joins the server the model either appears for them only (1/100,000 chance) or it doesn’t. How do I make such a thing?

I’m also adding an E to interact inside a part within this model (the model contains multiple parts), how do I make sure that the player can’t use the E to interact unless the model appears (1 in 100,000 chance)?

Please explain thoroughly as I’m not a good scripter.

If you wish for your model to only appear for the client, you will need a local script.

Since local scripts cant access ServerStorage you should put your model in replicated Storage

Then have a local script in the player that would work something like this

local plr = game.Players.LocalPlayer
local model = game.ReplicatedStorage["your model name"]

if math.random(1,100000) == 1 then
    local new = model:Clone()
    --do whatever you want from here
end
2 Likes

Hello, thanks for posting.

For the ‘one player’ all will need is to use a local script and for the ‘1 in 100,00 chance’ you will just need to use

math.random(1,100000)

here’s a basic script that I’ve design for you with text explaining what everything does :grinning:

--Using a local script means the it is executed on the client not the server so chanegs you make such as chaging a parts colour happens on the client so only they see it

local num = math.random(1,100000)--this picks a random number from 1 to 100000

if num == 1 then -- if the number is 1 which is a 1 in 1000000 chance then it will execute the code
	-- put here what u want to happen if the player does get the 1 in 100000 thing
end

--talking about the E to interact thing, set it to disabled and in the function above change the to enabled
3 Likes