What do you want to achieve? I want to be able to increment a players Rebirths when a textbutton is clicked using DataStore2
What is the issue? I can’t find a way to do what i said in the first question
What solutions have you tried so far? I have looked everywhere, Youtube, ScriptingHelpers and the DevForum
I do not have a datastore2 script yet since im looking for a way to increment an IntValue by clicking on a TextButton, i have however tried using Increment() to increment the Rebirths but that does not work, only when i do so in a Part.
I am not super good with scripting but i have some knowledge
Use a RemoteEvent to send a “rebirth request” to the server. Then validate the request on the server and if it’s valid, give them the rebirth:
--client, LocalScript
local Remote = game.ReplicatedStorage.RebirthRequest --remote
local Button = script.Parent --rebirth UI button
--when the button is pressed
Button.Activated:Connect(function()
--make the request
Remote:FireServer()
end)
--server, Script
local Remote = game.ReplicatedStorage.RebirthRequest --remote
--a validate function which returns true or false, based on if the player has enough currency
--replace the condition below with an actual condition
function Validate(player)
local player_has_enough_levels = true
if player_has_enough_levels then
return true
else
return false
end
end
--listen to the request
Remote.OnServerEvent:Connect(function(player)
if Validate(player) then
player.Rebirths += 1 --or IncrementAsync etc.
--also remove their currency, do necessary calculations so it can't be spammed
end
end)