So, i was gonna make a game where the rewarding system is contributing to the Data Stores This is just a line of code from my script.
local pdata = {}
function awardwin(player)
if player then
local data = pdata[player.userId]
local leader = player:FindFirstChild("leaderstats")
if leader and data then
data.wins = data.wins + 1
local stat = leader:FindFirstChild("Wins")
if stat then
stat.Value = data.wins
end
end
end
end
function awardpoints(player, points)
if player and points then
local data = pdata[player.userId]
local leader = player:FindFirstChild("leader")
if leader and data then
data.points = data.points + points
local stat = leader:FindFirstChild("Credits")
if stat then
stat.Value = data.points
data.xp = data.xp + (points * 2)
local xp = leader:FindFirstChild("XP")
if xp then
xp.Value = data.xp
end
end
end
end
end
for _, player in pairs(contestants) do
if player then
if gameresult == "MurderWon" and player == murderer then
awardwin(player)
awardpoints(player, 150)
elseif gameresult ~= "MurderWon" and player ~= murderer then
if player == sheriff then
awardwin(player)
awardpoints(player, 130)
else
awardwin(player)
awardpoints(player, 90)
end
end
end
end
Im not sure if your familiar with this...

1 comment
I don't see anything here that represents a datastore...