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

Is this correct?

Asked by 8 years ago

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.

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

1 answer

Log in to vote
2
Answered by
Marios2 360 Moderation Voter
8 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.

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
2
Make it to the Backpack and not StarterGear-- Gun1.Parent = player.Backpack XToonLinkX123 580 — 8y
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 — 8y
0
Put it in both so they get the tool to choose in the Backpack. Spongocardo 1991 — 8y
Ad

Answer this question