(Also to clarify: i tried other solutions but didn’t work)
Hi, so I’m getting this warning from the topic of course, So how do I fix this, bc when someone invokes this function it gets a setasync throttled error.
Also I’m doing a settings thing so that’s why I’m using Remote Function
Client Script
Client script:
local Config = script.Parent.Parent:WaitForChild("Config")
local GetSettings = script.Parent.Settings:InvokeServer("GetData", Config.Test)
local Settings = script.Parent.Settings
local debounce = false
local function sendValue()
Settings:InvokeServer("UpdateData", Config.Test)
end
local function updateValue()
Config.Test.Value = GetSettings
print(GetSettings)
end
Config.Test:GetPropertyChangedSignal("Value"):Connect(sendValue)
script.Parent.Toggle.Activated:Connect(function()
print("Click")
if Config.Test.Value == false then
sendValue()
print(Config.Test.Value)
Config.Test.Value = true
script.Parent.Toggle.Text = "On"
elseif Config.Test.Value == true then
sendValue()
print(Config.Test.Value)
Config.Test.Value = false
script.Parent.Toggle.Text = "Off"
end
end)
local function getValue()
updateValue()
if Config.Test.Value == true then
script.Parent.Toggle.Text = "On"
else
script.Parent.Toggle.Text = "Off"
end
end
getValue()
Server Side:
local Settings = script.Parent:WaitForChild("Settings")
local Config = script.Parent.Parent:WaitForChild("Config")
local DatastoreService = game:GetService("DataStoreService")
local TestValue = DatastoreService:GetDataStore("TestValue")
Settings.OnServerInvoke = function(player, valueupdater, data)
if valueupdater == "GetData" then
return TestValue:GetAsync("key_".. player.UserId)
elseif valueupdater == "UpdateData" then
TestValue:SetAsync("key_".. player.UserId, {data.Value})
end
end
GUI Folder:
Anything might help.