Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you set a random event?

so, pretend you want to give the user a random gear, without them choosing. How do I do that? I know, I need to watch some tutorials on scripting, but I really need to get my game done.

1 answer

✓ Accepted answer
  1. You're never going to make a game unless you make a game.
  2. This will require you to know how to make a game.
  3. This will require you to have an attempt so here's what mechanics will be involved in your described scenario:

You can research the below on wiki.roblox.com PlayerAdded Event will allow you to recognise when a player has joined the game CharacterAdded Event will allow you to recognise when a player's character has been generated (good for recognising when a player respawns) Object:Clone() Allows you to clone an object for reassignment (good for taking an object for replication but leaving the original where it is) ServerStorage and it's uses math.random() and how to use it

local gear = game.ServerStorage["GearStore"]:GetChildren() -- change this string to the name of the Folder or Model you're keeping your gear in

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		local randGear = gear[math.random(#gear)]:clone()
		randGear.Parent = plr.Backpack
	end
end

5 comments

0

^^ This

0

You didn't explain why gear, GetChildren, and math.random are/ should used like that. :P

0

Because he can google.

0

Not really, you just spoonfed him. You're responsible.

0

Bite me.

This discussion is preserved as it was. New answers, comments, and votes are closed.