alright so i was wanting a to make a player voting system but i want it where they can only vote on a player once in their entire existance which is easy to do on one server but im wanting it to save across all servers so they cant vote on somebody again in a different server gonna slap my script that will eventually change the boolvalue and im gonna post my Datastore2
script:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
local PlayerRating = Player:WaitForChild("PlayerRating")
local Rating = PlayerRating:WaitForChild("Rating")
local TheFolder = Instance.new("Folder")
TheFolder.Name = Player.Name
TheFolder.Parent = game.ServerStorage
local TheRating = Instance.new("IntValue")
TheRating.Parent = TheFolder
TheRating.Name = "Rating"
TheRating.Value = Rating.Value
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = char
ClickDetector.MouseClick:Connect(function(Player)
print(Player.Name.." Clicked "..ClickDetector.Parent.Name)
local OtherPlayer = game.Players:FindFirstChild(ClickDetector.Parent.Name)
local GuiClone = script.RatePlayer:Clone()
GuiClone.Parent = Player.PlayerGui
GuiClone.MainFrame.PlayerImage.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..OtherPlayer.UserId.."&width=420&height=420&format=png"
GuiClone.MainFrame.PlayerRating.Text = game.Players:FindFirstChild(OtherPlayer.Name).PlayerRating.Rating.Value
GuiClone.MainFrame.OtherPlayer.Value = OtherPlayer.Name
GuiClone.MainFrame.PlayerName.Text = OtherPlayer.Name
OtherPlayer.PlayerRating.Rating.Changed:Connect(function()
GuiClone.MainFrame.PlayerRating.Text = OtherPlayer.PlayerRating.Rating.Value
end)
end)
end)
end)
Datastore2 Script:
local DS2 = require(1936396537)
local runservice = game:GetService("RunService")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstatsData = DS2('leaderstats', plr)
local donthurtmeData = DS2('nolove', plr)
local ratedata = DS2('rates',plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = leaderstats
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Parent = leaderstats
local Lollipop = Instance.new("IntValue")
Lollipop.Name = "Kills"
Lollipop.Parent = leaderstats
for i,v in pairs (leaderstats:GetChildren()) do
v.Changed:connect(function()
local Saving = {
["Level"] = (plr.leaderstats).Level.Value;
["Coins"] = (plr.leaderstats).Coins.Value;
["Lollipop"] = (plr.leaderstats).Kills.Value;
}
leaderstatsData:Set(Saving)
print('Saved '..plr.Name..'s leaderstats Data')
end)
end
print("Gave "..plr.Name.." leaderstats Data")
local SavedItems = leaderstatsData:Get(nil)
if SavedItems then
Level.Value = SavedItems.Level or 0
Coins.Value = SavedItems.Coins or 0
Lollipop.Value = SavedItems.Lollipop or 0
print(plr.Name.." had leaderstats Data")
else
Level.Value = 0
Coins.Value = 0
Lollipop.Value = 0
print(plr.Name.." didn't have leaderstats Data")
end
local Requirements = Instance.new("Folder")
Requirements.Name = "Requirements"
Requirements.Parent = plr
local RequiredKills = Instance.new("IntValue")
RequiredKills.Name = "RequiredKills"
RequiredKills.Parent = Requirements
for i,v in pairs (Requirements:GetChildren()) do
v.Changed:connect(function()
local Saving = {
["RequiredKills"] = (plr.Requirements).RequiredKills.Value;
}
donthurtmeData:Set(Saving)
print('Saved '..plr.Name..'s Requirements Data')
end)
end
print("Gave "..plr.Name.." Requirements Data")
local SavedItems = donthurtmeData:Get(nil)
if SavedItems then
RequiredKills.Value = SavedItems.RequiredKills or 15
print(plr.Name.." had Requirements Data")
else
RequiredKills.Value = 15
print(plr.Name.." didn't have Requirements Data")
end
local PlayerRating = Instance.new("Folder")
PlayerRating.Name = "PlayerRating"
PlayerRating.Parent = plr
local Rating = Instance.new("IntValue")
Rating.Name = "Rating"
Rating.Parent = PlayerRating
for i,v in pairs (PlayerRating:GetChildren()) do
v.Changed:Connect(function()
local Saving = {
["Rating"] = (PlayerRating).Rating.Value;
}
ratedata:Set(Saving)
print('Saved '..plr.Name..'s Rating Data')
end)
end
print("Gave "..plr.Name.." Rating Data")
local SavedItems = ratedata:Get(nil)
if SavedItems then
Rating.Value = SavedItems.Rating or 0
print(plr.Name.." had Rating Data")
else
Rating.Value = 0
print(plr.Name.." didn't have Rating Data")
end
end)
game:BindToClose(function()
if runservice:IsStudio() then
return
else
wait(3)
end
end)
