Collection with Bag

Scripts

Leaderboards

local function onPlayerJoin(player)

local leaderstats = Instance.new("Folder")

leaderstats.Name = "leaderstats"

leaderstats.Parent = player


local coins = Instance.new("IntValue")

coins.Name = "Coins"

coins.Value = 0

coins.Parent = leaderstats


local bag = Instance.new("IntValue")

bag.Name = "Bag"

bag.Value = 0

bag.Parent = leaderstats

end


game.Players.PlayerAdded:Connect(onPlayerJoin)

Sell Pad

local part = script.Parent


local function collect(otherPart)

local player = game.Players:FindFirstChild(otherPart.Parent.Name)

if player then

local playerBag = player.leaderstats.Bag.Value

if playerBag > 0 then

player.leaderstats.Bag.Value = 0

player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + (playerBag * 25)

end

end

end


part.Touched:Connect(collect)

Part

local part = script.Parent

local addPoint = true



local function collect(otherPart)

local player = game.Players:FindFirstChild(otherPart.Parent.Name)

if player and addPoint then

local playerBag = player.leaderstats.Bag.Value

if playerBag < 3 then

addPoint = false

player.leaderstats.Bag.Value = player.leaderstats.Bag.Value + 1

part.Position = Vector3.new(math.random(-100,100),part.Position.Y, math.random(-100,100))

wait(1)

addPoint = true

end

end

end


part.Touched:Connect(collect)