Hello, I am trying to get my datastore to save my number value. The number value is basically the amount of kicks a player must receive before getting Banned permanently! Also, This Datastore is connected to my System Message chat filter since, I want to prevent Staff from abusing the Server Messages by posting inappropriate content. Please Read the link where the script isn’t working.
local datastore = game:GetService("DataStoreService")--Gets the service
local ds1 = datastore:GetDataStore("DataSaver")
game.Players.PlayerAdded:Connect(function(plr)--When a player joins
local MaxCountbeforeBan = 9
local count = game.StarterGui.AdminMessage.ControlScript.count
count.Value = ds1:GetAsync(plr)--Loads the money
ds1:SetAsync(plr, count.Value)
print("Loaded in the Counter for number of Kicks")
--Below this line doesn't work!
count.Changed:connect(function()--Saves the money
ds1:SetAsync(plr, count.Value)
print("Counter Saved!")
if count >= MaxCountbeforeBan then
plr:Kick("You have been Banned for Excessive Swearing!")
end
end)
end)