Hello i need some help with saving and adding up my value using profileservice.
I havent scripted in a year and i got bored and wanted to make a mute system but i cant seem to save or add up value on warnings.
My datastore script
this is a module in replicated storage.
local Players = game:GetService("Players")
local ProfileService = require(game.ReplicatedStorage.ProfileService)
local ProfileStore = ProfileService.GetProfileStore(
"Player",
{
Warnings = 0;
Timemute = 0;
}
)
local Profiles = {}
local function onPlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync(
"Player_"..player.UserId,
"ForceLoad"
)
if profile then
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick()
end)
if player:IsDescendantOf(Players) then
Profiles[player] = profile
else
profile:Release()
end
else
player:Kick()
end
end
local function GiveWarn(player, amount)
print("Working")
local data = Profiles[player]
if data ~= nil then
data.Warnings += 1
player.Values.Warnings.Value += data.Warnings
else print(player .. ' was not found.') end
end
local function onPlayerRemoving(player)
local profile = Profiles[player]
if profile then
profile:Release()
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)
game.ReplicatedStorage.SaidBadWord.OnServerEvent:Connect(GiveWarn)
local DataManager = {}
function DataManager:Get(player)
local profile = Profiles[player]
if profile then
return profile
end
end
return DataManager
The GiveWarn function doesnt seem to work.
Here is where i call it.
Had to say badword in the table
This is a script in serverscriptservice
local array = {
"badword",
"badword",
"badword",
"badword",
"badword",
"badword",
}
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
for i,v in pairs (array) do
if string.match(string.lower(msg), v) then
game.ReplicatedStorage.SaidBadWord:FireClient(player)
end
end
end)
end)