First of all i don't think you need a function
Make a part and add a click-detector and a script in it
We need to create a leaderstats in the script.
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Clicks = Instance.new("IntValue", leaderstats)
Clicks.Name = "Clicks"
end)
Now make another script in the part
Type this in the script
local ClickDetector = script.Parent.ClickDetector
ClickDetector.MouseClick:Connect(function(player)
local Clicks = player.leaderstats.Clicks
Clicks.Value = Clicks.Value + 1
end)
You can also make it with a tool everytime it gets activated it adds one, but then you need remote functions which you will learn later on.
5 comments
I don't get what you're trying to do????
A point system for when you click something.
Oh!
Then make your question more constructive, and also, this is not a script request site. Try the script for yourself and if gives an error, come back to ask us what is wrong.
Also look at zamdi's answer he helped me too, with my DataStore error!