Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you set a random event?

Asked by 8 years ago

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

Log in to vote
2
Answered by
Pejorem 164
8 years ago
  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
0
^^ This Meltdown81 309 — 8y
0
You didn't explain why gear, GetChildren, and math.random are/ should used like that. :P TheeDeathCaster 2368 — 8y
0
Because he can google. Pejorem 164 — 8y
0
Not really, you just spoonfed him. You're responsible. LightModed 81 — 8y
0
Bite me. Pejorem 164 — 7y
Ad

Answer this question