Click for Points
Making a Button
1. Under StarterGui add a ScreenGui
2. Under ScreenGui add a TextButton
3. Under TextButton add a LocalScript
Code for LocalScript
local button = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local addPointEvent = ReplicatedStorage:WaitForChild("AddPoint")
button.MouseButton1Click:Connect(function()
addPointEvent:FireServer()
end)
Script under ServerScriptService
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points= Instance.new("IntValue")
points.Name = "Points"
points.Value = 50
points.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
-- Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local addPointEvent = Instance.new("RemoteEvent", ReplicatedStorage)
addPointEvent.Name = "AddPoint"
local function addPoints(player)
local p = game.Players:FindFirstChild(player.Name)
if p then
p.leaderstats.Points.Value = p.leaderstats.Points.Value + 1
end
end
addPointEvent.OnServerEvent:Connect(addPoints)