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

How to check if player did a obstacle course?

So i am doing a game, and i need for it to check, if player did the obstacle course, well, i could use data stores, but it won't be as effective as it needs to.

dataStore = game:GetService("DataStoreService")
obbyStore1 = dataStore:GetDataStore("ObbyStore1")

-- and such stuff

Is there any better way?

2 comments

0

If the player touches the finish part, you could signal that they have completed it, no? Using that part's Touched event? Or do you aim to do it a different way?

0

You can also increase a number value by 1 at several points on the obby where the player touches a part and then check if the number matches the number it should. This way it is way more difficult to cheat.

2 answers

✓ Accepted answer

Assuming the script is in a block that detects if they reached it, your script would be:

dataStore = game:GetService("DataStoreService")
obbyStore1 = dataStore:GetDataStore("ObbyStore1")

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:FindFirstChild(hit.Parent.Name)
	if player then
		--check if theyre in the obby datastore
		local hasCompletedObby = obbyStore1:GetAsync(player.UserId)
		
		--if theyre not in ds/ reward player and add them to the datastore
		if(not hasCompletedObby)then
			--TODO: reward player for completing obby
			obbyStore1:SetAsync(player.UserId)
		end
	end
end)

3 comments

0

Sorry, this is not what i need, i am needing to know if player did the obstacle course, but points won't add if he will reach it again

0

i updated the post to have the proper answer

0

this is what i need, but now i need to know how to know total amount of obstacle courses beaten

(this is repeating of commect i posted) Ok thanks, now i know if player already did the obstacle course, but i need to know total amount of obstacle courses, because it's not just 1 obby

dataStore = game:GetService("DataStoreService")
obbyStore1 = dataStore:GetDataStore("ObbyStore1")
obbyStore2 = dataStore:GetDataStore("ObbyStore2")

1 comment

0

i will probably make another question

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