01 | game.Players.PlayerAdded:Connect( function (plr) |
02 | local stats = Instance.new( "Folder" ) |
03 | stats.Name = "leaderstats" |
04 | stats.Parent = plr |
05 |
06 | local DP = Instance.new( "IntValue" ) |
07 | DP.Name = "Points" |
08 | DP.Parent = stats |
09 |
10 | local DR = Instance.new( "IntValue" ) |
11 | DR.Name = "Dice Rolls" |
12 | DR.Parent = stats |
13 |
14 | end ) |
15 |
What I want the script to do: Make leaderstats so it can add 1 to DR on click of its parent ImageButton.
What the script does: Keep it from being clicked over and over.
The Script is inside an ImageButton that is inside a ScreenGui inside StarterGui.
Hey! I believe I found your issue. The problem is that you're changing the leader stats value in a local script.
Before we begin, please make a RemoteEvent in ReplicatedStorage, and call it RemoteEvent
The local script:
01 | script.Parent.MouseButton 1 Click:Connect( |
02 | function () |
03 | local player = game.Players.LocalPlayer |
04 | local remoteEvent = game.ReplicatedStorage.RemoteEvent |
05 | remoteEvent:FireServer(player) |
06 | script.Parent.Visible = false |
07 | script.Parent.Parent.StClOnRB.Visible = true |
08 | wait( 2.5 ) |
09 | script.Parent.Visible = true |
10 | script.Parent.Parent.StClOnRB.Visible = false |
11 | script.Parent.Parent.StClOnRB.Selectable = false |
12 | end |
13 | ) |
a server script in serverscriptservice
01 | game.Players.PlayerAdded:Connect( |
02 | function (plr) |
03 | local stats = Instance.new( "Folder" ) |
04 | stats.Name = "leaderstats" |
05 | stats.Parent = plr |
06 |
07 | local DP = Instance.new( "IntValue" ) |
08 | DP.Name = "Points" |
09 | DP.Parent = stats |
10 |
11 | local DR = Instance.new( "IntValue" ) |
12 | DR.Name = "Dice Rolls" |
13 | DR.Parent = stats |
14 | end |
15 | ) |
16 | game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect( |
17 | function (player) |
18 | player.leaderstats [ "Dice Rolls" ] .Value + = 1 |
19 | end |
20 | ) |