Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Leaderboard Not Working?

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

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.
]]--
Ad

Answer this question