Hi, I made scripts that make a part and you collect them and I want to make a part counter I have these scripts,
game.Players.PlayerAdded:Connect(function (player)
local leaderstats = Instance.new("Folder")
leaderstats.Parent = player
leaderstats.Name = "leaderstats"
local thingyCoin = Instance.new("IntValue")
thingyCoin.Name = "parts"
thingyCoin.Value = 0
thingyCoin.Parent = leaderstats
end)
and the collector from the part
local part = script.Parent
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
if humanoid then
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
player.leaderstats.parts.Value = player.leaderstats.parts.Value + 1
script.Parent:Destroy()
end
end
end
part.Touched:Connect(onTouch)
and here's the script that adds the part
local part = game.ServerStorage.Part
local yPOS = 100
while true do
local partClone = part:Clone()
partClone.Parent = game.Workspace["parts lollll"]
local xPOS = math.random(-253.94, 254.925)
local zPOS = math.random(-254.925, 253.94)
partClone.Position = Vector3.new(xPOS, yPOS, zPOS)
partClone.BrickColor = BrickColor.Random()
wait()
end
thanks if you can help
