Touch for Points

Leaderstats Script (ServerScriptService)

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 = 50

coins.Parent = leaderstats

end


game.Players.PlayerAdded:Connect(onPlayerJoin)

Script for Part

local part = script.Parent

local canGet = true


local function onTouch(otherPart)

local humanoid = otherPart.Parent:FindFirstChild('Humanoid')

if humanoid then

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

if player and canGet then

canGet = false

player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1

wait(10)

canGet = true

end

end

end


part.Touched:Connect(onTouch)