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

The weapon is duplicating when I resetted?

Asked by 7 years ago
local gamepass = script:WaitForChild("GamePassId")
local service = game:GetService("GamePassService")


game.Players.PlayerAdded:connect(function(player) if service:PlayerHasPass(player,gamepass.Value)
 then local tools = game.ReplicatedStorage:WaitForChild("Tools")
 for i,v in pairs(tools:GetChildren()) do 
  if v:isA("Tool") then
   v:Clone().Parent = player:WaitForChild("Backpack")
   v:Clone().Parent = player.WaitForChild("StarterGear")
  end
 end
end
end)

2 answers

Log in to vote
-1
Answered by 7 years ago

I think the PlayerAdded event will fire when you die somehow. To prevent this insert a BoolValue in the charachter.

local gamepass = script:WaitForChild("GamePassId")
local service = game:GetService("GamePassService")

game.Players.PlayerAdded:connect(function(player) if service:PlayerHasPass(player,gamepass.Value)
 then local tools = game.ReplicatedStorage:WaitForChild("Tools")
 for i,v in pairs(tools:GetChildren()) do 
    local boolvalue = Instance.new("BoolValue",player)
  if v:isA("Tool") and not boolvalue then
    v:Clone().Parent = player:WaitForChild("Backpack")
    v:Clone().Parent = player.WaitForChild("StarterGear")
    boolvalue.Value = true
  end
 end
end
end)

If this helps you let me know im not that good in scripting :)

0
It doesn't work WTFITSAHACKER -5 — 7y
0
Sorry then i can't help you. Ernie252 -4 — 7y
Ad
Log in to vote
-1
Answered by
yyyyyy09 246 Moderation Voter
7 years ago
local gamepass = script:WaitForChild("GamePassId")
local service = game:GetService("GamePassService")


game.Players.PlayerAdded:connect(function(player) 
    if service:PlayerHasPass(player,gamepass.Value) then

        local tools = game.ReplicatedStorage:WaitForChild("Tools")

        for i,v in pairs(tools:GetChildren()) do 

            if v:isA("Tool") then

                v:Clone().Parent = player:WaitForChild("Backpack")
                v:Clone().Parent = player.WaitForChild("StarterGear") -- You have a period instead of a colon player.WaitForChild

            end
        end
    end
end)

Hope this helps <3

Answer this question