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)
COMMUNITY QUESTION
The weapon is duplicating when I resetted?
2 answers
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 :)
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
It doesn't work
Sorry then i can't help you.