Im making a game. And I wanna give guns out every 60 seconds and remove them every 40 seconds. Is this correct?
Gun1 = game.ServerStorage.Deagle while true do wait(60) Gun1.Parent = game.Players.Player.Backpack wait(40) Gun1.Parent = game.ServerStorage end
It would be helpfull if you could correct my errors.
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.
while true do wait(60) for _,player in pairs(game.Players:GetPlayers()) do --Get all current players 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. GunD.Parent = player.StarterGear end wait(40) for _,player in pairs(game.Players:GetPlayers()) do --Get all current players, again player.StarterGear:FindFirstChild("Deagle"):Destroy() --If the gun exists, remove it player.Character:FindFirstChild("Deagle"):Destroy() --The gun can also be in the player's character too end end