game.Players.PlayerAdded:Connect(function(plr) local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = plr local DP = Instance.new("IntValue") DP.Name = "Points" DP.Parent = stats local DR = Instance.new("IntValue") DR.Name = "Dice Rolls" DR.Parent = stats end) local Player = game.Players.LocalPlayer local DR = Instance.new("IntValue") script.Parent.MouseButton1Click:Connect(function() Player.leaderstats["Dice Rolls"].Value += 1 script.Parent.Visible = false script.Parent.Parent.StClOnRB.Visible = true wait(2.5) script.Parent.Visible = true script.Parent.Parent.StClOnRB.Visible = false script.Parent.Parent.StClOnRB.Selectable = false end)
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:
script.Parent.MouseButton1Click:Connect( function() local player = game.Players.LocalPlayer local remoteEvent = game.ReplicatedStorage.RemoteEvent remoteEvent:FireServer(player) script.Parent.Visible = false script.Parent.Parent.StClOnRB.Visible = true wait(2.5) script.Parent.Visible = true script.Parent.Parent.StClOnRB.Visible = false script.Parent.Parent.StClOnRB.Selectable = false end )
a server script in serverscriptservice
game.Players.PlayerAdded:Connect( function(plr) local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = plr local DP = Instance.new("IntValue") DP.Name = "Points" DP.Parent = stats local DR = Instance.new("IntValue") DR.Name = "Dice Rolls" DR.Parent = stats end ) game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect( function(player) player.leaderstats["Dice Rolls"].Value += 1 end )