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

Is this correct?

Asked by 9 years ago

Im making a game. And I wanna give guns out every 60 seconds and remove them every 40 seconds. Is this correct?

1Gun1 = game.ServerStorage.Deagle
2while true do
3    wait(60)
4    Gun1.Parent = game.Players.Player.Backpack
5    wait(40)
6    Gun1.Parent = game.ServerStorage
7 
8end

It would be helpfull if you could correct my errors.

2
Why not test it and if you have any errors correct them yourself? Perci1 4988 — 9y

1 answer

Log in to vote
2
Answered by
Marios2 360 Moderation Voter
9 years ago

1) You could see if it is correct by yourself

2) For crying out loud, that script is only for a player called "Player", and if there is no player called that, it breaks.

At least, however, you showed us a script so you actually attempted to do this. Now here's one thing you should always remember: Clone(), local and for are some of your best friends.

01while true do
02    wait(60)
03    for _,player in pairs(game.Players:GetPlayers()) do --Get all current players
04        local GunD = game.ServerStorage.Deagle:Clone() --Make it a local variable as we're only using it here, and update it so we get a copy of it for every player. Also use only letters in variables.
05        GunD.Parent = player.StarterGear
06    end
07    wait(40)
08    for _,player in pairs(game.Players:GetPlayers()) do --Get all current players, again
09        player.StarterGear:FindFirstChild("Deagle"):Destroy() --If the gun exists, remove it
10        player.Character:FindFirstChild("Deagle"):Destroy() --The gun can also be in the player's character too
11    end
12end
2
Make it to the Backpack and not StarterGear-- Gun1.Parent = player.Backpack XToonLinkX123 580 — 9y
0
If an item is in StarterGear, it doesn't get lost when the player dies. If it is in Backpack, however, it gets lost. It's up to digitalzer to decide. Marios2 360 — 9y
0
Put it in both so they get the tool to choose in the Backpack. Spongocardo 1991 — 9y
Ad

Answer this question