Greetings. I am trying to find a way in order to change a certain user’s amount of points in my game, but cannot seem to figure it out. I was told that DataBase editor would supposedly be able to help. But I do not know anything about the DataBase editor, nor if I even need to use Database editor. Could someone tell me the name, the scope, and the key, or another way to change someone’s points?
This is for a hand to system., where staff get points when they handto.
script.Parent.GiveItem.OnServerEvent:connect(function(plr, customer, order)
pcall(function()
if customer ~= nil and order ~= nil then
local gui = script.Parent.reciever:Clone()
gui.barista.Value = plr.Name
order.Parent = gui
gui.Frame.question.Text = "Would you like to recieve "..order.Name.." from " .. plr:GetRoleInGroup(script.Parent.GroupID.Value)..", "..plr.Name.."?"
gui.Parent = customer.PlayerGui
end
end)
end)
local array = {}
function update(plr,points)
for i=1,10 do
if workspace.pointsboard.SurfaceGui.Frame["p"..i].plrname.Text == plr then
if i~= 10 then
for a=i+1, 10 do
workspace.pointsboard.SurfaceGui.Frame["p"..a-1].plrname.Text = workspace.pointsboard.SurfaceGui.Frame["p"..a].plrname.Text
workspace.pointsboard.SurfaceGui.Frame["p"..a-1].plrpoints.Text = workspace.pointsboard.SurfaceGui.Frame["p"..a].plrpoints.Text
end
end
workspace.pointsboard.SurfaceGui.Frame.p10.plrname.Text = ""
workspace.pointsboard.SurfaceGui.Frame.p10.plrpoints.Text = "0"
break
end
end
--add the swap ranks bit here!
local num = 0
for i=1, 10 do
if points > tonumber(workspace.pointsboard.SurfaceGui.Frame["p"..i].plrpoints.Text) then
num = i
break
end
end
if num ~= 0 then
for i=1,10-num do
workspace.pointsboard.SurfaceGui.Frame["p"..(11-i)].plrpoints.Text = workspace.pointsboard.SurfaceGui.Frame["p"..(10-i)].plrpoints.Text
workspace.pointsboard.SurfaceGui.Frame["p"..(11-i)].plrname.Text = workspace.pointsboard.SurfaceGui.Frame["p"..(10-i)].plrname.Text
end
workspace.pointsboard.SurfaceGui.Frame["p"..(num)].plrpoints.Text = points
workspace.pointsboard.SurfaceGui.Frame["p"..(num)].plrname.Text = plr
end
return
end
game.Players.PlayerAdded:connect(function(player)
--Stuff that defo works--
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local rank = Instance.new("StringValue", leaderstats)
rank.Name = "Rank"
rank.Value = player:GetRoleInGroup(script.Parent.GroupID.Value)
if player:GetRankInGroup(script.Parent.GroupID.Value) >= script.Parent.RankID.Value or player.Name == "Wizzy011" or player.Name == "Player1" then
local points = Instance.new("IntValue", leaderstats)
points.Name = "Points"
points.Value = game:GetService("DataStoreService"):GetDataStore("Points"):GetAsync("user_" ..player.userId)
array[player.Name] = points.Value
update(player.Name, points.Value)
else
local points = Instance.new("StringValue", leaderstats)
points.Name = "Points"
points.Value = "N/A"
end
if player:GetRankInGroup(script.Parent.GroupID.Value) >= script.Parent.AdminRankID.Value or player.Name == "MysteriouslyMythical" then
player.Chatted:connect(function(msg)
if string.sub(msg, 0,10) == "addpoints " then
local nameend = string.find(msg, " ",11)
if nameend ~= nil then
local name = string.sub(msg, 11, nameend-1)
local client = nil
local count = 0
for _,v in pairs(game.Players:GetPlayers()) do
if string.lower(name) == string.lower(string.sub(v.Name,0,string.len(name))) then
client = v.Name
count = count+1
end
end
if count == 1 then
local points = string.sub(msg, nameend)
if tonumber(points) ~= nil then
if array[client] ~= nil then
array[client] = array[client] + points
pcall(function()
game.Players[client].leaderstats.Points.Value = array[client]
end)
update(client, array[client])
end
end
end
end
elseif string.sub(msg, 0,13) == "revokepoints " then
local nameend = string.find(msg, " ",14)
if nameend ~= nil then
local name = string.sub(msg, 14, nameend-1)
local client = nil
local count = 0
for _,v in pairs(game.Players:GetPlayers()) do
if string.lower(name) == string.lower(string.sub(v.Name,0,string.len(name))) then
client = v.Name
count = count+1
end
end
if count == 1 then
local points = string.sub(msg, nameend)
if tonumber(points) ~= nil then
if array[client] ~= nil then
array[client] = array[client] - points
pcall(function()
game.Players[client].leaderstats.Points.Value = array[client]
end)
update(client, array[client])
end
end
end
end
end
end)
end
end)
script.Parent.AddPoint.OnServerEvent:connect(function(cus,p)
plr = game.Players:FindFirstChild(p)
if plr ~= nil then
plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +1
array[plr.Name] = plr.leaderstats.Points.Value
update(p, array[plr.Name])
end
end)
script.Parent.RevokePoint.OnServerEvent:connect(function(cus,p)
plr = game.Players:FindFirstChild(p)
if plr ~= nil then
plr.leaderstats.Points.Value = plr.leaderstats.Points.Value -1
--------
array[plr.Name] = plr.leaderstats.Points.Value
update(p, array[plr.Name])
end
end)
game.Players.PlayerRemoving:connect(function(player)
if array[player.Name] ~= nil then
game:GetService("DataStoreService"):GetDataStore("Points"):UpdateAsync("user_"..player.userId, function(oldValue)
local newValue = array[player.Name]
local val = newValue
return newValue
end)
wait()
array[player.Name] = nil
update(player.Name, -1000)
end
end)