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

A random gun spawn?

Asked by
lucas4114 607 Moderation Voter
9 years ago

So, I'm not a pro at scripiting and this is the first time in using a random function thing for my games, I'm want to make 1 of the 5 guns i have randomly spawn in a players backpack when he respawns.... How would I do that..

1 answer

Log in to vote
2
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

First you would want to use the PlayerAdded event to connect to a player, and identify if they have respawned or not. You can use the CharacterAdded event to do so. Then you would want to use the math.random function to index a tool in storage and parent it to the spawning player's backpack.

Unless you provide attempt for a script, I can not help all that much or else you would not be benefiting from attempting it. I will help you set up the functions though real quick.

game.Players.PlayerAdded:connect(function(plr) --So a player was added, and we're calling him player.
    plr.CharacterAdded:connect(function() --This sill fire the function if the player respawns. 
        --You must finish the rest of the code here, post a new question if you have difficulty getting something to work.
    end) --End the CharacterAdded function.
end) --We'll end the function for PlayerAdded.

Once again, we can not help you unless you make a attempt at a script. Thank you for your understanding.

0
Yeah now I got a basic idea what how to make my script so now I'll try... lucas4114 607 — 9y
0
It works!! Thank you!! lucas4114 607 — 9y
Ad

Answer this question