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

Reset leaderstat value AND Datastore through GUI Button?

Asked by 6 years ago

So I want to make a textbutton that when you click it, it resets your stage, and your DataStore. How would I do this in FilteringEnabled?

This is the script I made with a REGULAR SCRIPT in a TextButton. I know regular scripts don't work in TextButtons, but I'm confused, as you can't access DataStore through LocalScripts.

local data = game:GetService("DataStoreService"):GetDataStore("Stage")

script.Parent.MouseButton1Up:connect(function(player)
    player.leaderstats.Stage.Value = 0
    local key = "user_" .. player.userId
    data:SetAsync(key, player.leaderstats.Stage.Value)
end)

Please help!

1 answer

Log in to vote
0
Answered by
Simnico99 206 Moderation Voter
6 years ago

This is the way to make localscript communicate with server script

https://www.youtube.com/watch?v=C0qQ4lDa3t0

Here a video tutorial

Ad

Answer this question