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

Is this correct?

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 comment

2

Why not test it and if you have any errors correct them yourself?

1 answer

✓ Accepted answer
  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

3 comments

2

Make it to the Backpack and not StarterGear-- Gun1.Parent = player.Backpack

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.

0

Put it in both so they get the tool to choose in the Backpack.

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