Click Part For Points

Leaderstats (ServerScriptService)

local function onPlayerJoin(player)

local leaderstats = Instance.new("Folder")

leaderstats.Name = 'leaderstats'

leaderstats.Parent = player

local clicks = Instance.new('IntValue')

clicks.Name = 'Clicks'

clicks.Value = 0

clicks.Parent = leaderstats

end


game.Players.PlayerAdded:Connect(onPlayerJoin)

Script (Under Part)

local part = script.Parent

local click = part.ClickDetector

local clickAmount = 0

local canClick = true

local function addClick(player)

if canClick then

player.leaderstats.Clicks.Value = player.leaderstats.Clicks.Value + 1

clickAmount = clickAmount + 1

end

if clickAmount >= 10 then

clickAmount = 0

canClick = false

part.BrickColor = BrickColor.new('Really red')

wait(3)

part.BrickColor = BrickColor.new('Medium stone grey')

canClick = true

end

end


click.MouseClick:Connect(addClick)

For a Tool

local tool = script.Parent

local canClick = true


local function onClick()

if canClick then

canClick = false

local str = Instance.new("StringValue")

str.Name = "toolanim"

str.Value = "Slash"

str.Parent = tool

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

player.leaderstats.Clicks.Value = player.leaderstats.Clicks.Value + 1

wait(1)

canClick = true

end

end


tool.Activated:Connect(onClick)