Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Leaderboard Not Working?

I am attempting to make a leader board that when you click a certain button in a Gui it adds a point. It isn't working and I don't know why...

players = game:GetService('Players')
startingcash = 0
-- Variables

players.PlayerAdded:connect(function(plr)
local stats = Instance.new('IntValue')
local cash = Instance.new('IntValue')
stats.Name = 'leaderstats'
cash.Name = 'Points'
cash.Parent = stats
cash.Value = startingcash
stats.Parent = plr
local AddPointGui = script.Parent.Parent.StarterGui.HandtoGui.Accept.Yes
AddPointGui.MouseButton1Click:connect(function()
	cash.Value = cash.Value + 1
end)
end)

1 answer

✓ Accepted answer

The reason this script doesn't work is because "AddPointGui" is never being referred to as the "AddPointGui" in the playerGUI.

This script should fix your problem.

local Players = game:GetService('Players') 
local StartingPoints = 0 
-- Variables 

Players.PlayerAdded:connect(function(Player) 
local Stats = Instance.new('IntValue')  
local Points = Instance.new('IntValue') 
Stats.Name = "leaderstats"
Points.Name = "Points"
Points.Parent = Stats 
Points.Value = StartingPoints 
Stats.Parent = Player 
local AddPointGui = Player.PlayerGui.HandtoGui.Accept.Yes  
	AddPointGui.MouseButton1Click:connect(function() 
	    Points.Value = Points.Value + 1 
	end) 
end) 

--[[
"Don't use "script.Parent.Parent.StarterGui" because that is accessing the StarterGui under "game" not the local players gui.
]]--

This discussion is preserved as it was. New answers, comments, and votes are closed.