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

01players = game:GetService('Players')
02startingcash = 0
03-- Variables
04 
05players.PlayerAdded:connect(function(plr)
06local stats = Instance.new('IntValue')
07local cash = Instance.new('IntValue')
08stats.Name = 'leaderstats'
09cash.Name = 'Points'
10cash.Parent = stats
11cash.Value = startingcash
12stats.Parent = plr
13local AddPointGui = script.Parent.Parent.StarterGui.HandtoGui.Accept.Yes
14AddPointGui.MouseButton1Click:connect(function()
15    cash.Value = cash.Value + 1
16end)
17end)

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.

01local Players = game:GetService('Players')
02local StartingPoints = 0
03-- Variables
04 
05Players.PlayerAdded:connect(function(Player)
06local Stats = Instance.new('IntValue'
07local Points = Instance.new('IntValue')
08Stats.Name = "leaderstats"
09Points.Name = "Points"
10Points.Parent = Stats
11Points.Value = StartingPoints
12Stats.Parent = Player
13local AddPointGui = Player.PlayerGui.HandtoGui.Accept.Yes 
14    AddPointGui.MouseButton1Click:connect(function()
15        Points.Value = Points.Value + 1
View all 21 lines...
Ad

Answer this question