Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Rewarding system contributing with Data Store problem, help?

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

0

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

1 answer

Sir, your question does not pertain to any use of DataStore, nor is it actually a problem with the DataStore systems. Furthermore, we do not understand what the problem with your code is, or if there even is a problem at all.

This website is for solving scripting errors, and for explanation on ROBLOX functions. Please review this page for How to Post Good Questions and Answers.

If you have attempted to utilize DataStores, please post your attempt. At that point we could help you if you state the problem, the error, and the attempt. From what it appears, it looks like you want us to implement a DataStore for you, which is considered a request, and is against site rules.

This discussion is preserved as it was. New answers, comments, and votes are closed.