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...
01 | players = game:GetService( 'Players' ) |
02 | startingcash = 0 |
03 | -- Variables |
04 |
05 | players.PlayerAdded:connect( function (plr) |
06 | local stats = Instance.new( 'IntValue' ) |
07 | local cash = Instance.new( 'IntValue' ) |
08 | stats.Name = 'leaderstats' |
09 | cash.Name = 'Points' |
10 | cash.Parent = stats |
11 | cash.Value = startingcash |
12 | stats.Parent = plr |
13 | local AddPointGui = script.Parent.Parent.StarterGui.HandtoGui.Accept.Yes |
14 | AddPointGui.MouseButton 1 Click:connect( function () |
15 | cash.Value = cash.Value + 1 |
16 | end ) |
17 | end ) |
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.
01 | local Players = game:GetService( 'Players' ) |
02 | local StartingPoints = 0 |
03 | -- Variables |
04 |
05 | Players.PlayerAdded:connect( function (Player) |
06 | local Stats = Instance.new( 'IntValue' ) |
07 | local Points = Instance.new( 'IntValue' ) |
08 | Stats.Name = "leaderstats" |
09 | Points.Name = "Points" |
10 | Points.Parent = Stats |
11 | Points.Value = StartingPoints |
12 | Stats.Parent = Player |
13 | local AddPointGui = Player.PlayerGui.HandtoGui.Accept.Yes |
14 | AddPointGui.MouseButton 1 Click:connect( function () |
15 | Points.Value = Points.Value + 1 |