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

How would I make it so that my Script creates a leaderboard so it can add 1 to one of its stats?

Asked by 4 years ago
01game.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 
14end)
15 
View all 26 lines...

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.

0
wait, is this a server script or local? and where is it located raid6n 2196 — 4y
0
wait, is this a server script or local? and where is it located raid6n 2196 — 4y
1
it used to be a script but i changed it to a local script since you wnated to use a local script Jakob_Cashy 79 — 4y

1 answer

Log in to vote
1
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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:

01script.Parent.MouseButton1Click: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

01game.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)
16game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(
17    function(player)
18        player.leaderstats["Dice Rolls"].Value += 1
19    end
20)
1
cool it works Jakob_Cashy 79 — 4y
1
thanks for the help Jakob_Cashy 79 — 4y
Ad

Answer this question