Need assistance with a script ive been stressing about for over a month!

Sorry for reposting this but I’m trying to fix a timer in my obby so people can have fun competing. The rest of the scripts for the timer and the leaderboard work perfectly fine but I just wanted the script to do the opposite of what the youtuber put at the top! I want to make it so that even if the player dies from start to finish, they can have a time on the leaderboard still. Like I said, it works flawlessly but I just want to make it so that even if the player dies from when they touch the StartTimer and the EndTimer, they can still have a spot on the leaderboard! Only things I changed in this script is the Datastore thingy that says “leaderboardData5” and the Anti-cheat timer! Pay attention to the words at the top of the script please!

--[[
	@author TwinPlayzDev_YT
	@since 6/1/2021
	This script will apply the leaderboard time, and check if a player has finished or completed the obby.
	Only saves time when they fully complete course without dieing.
--]]

-- [ SERVICES ] --

local DataStoreService = game:GetService("DataStoreService")

-- [ LOCALS ] --

local DataVer = "[DataTimer]" -- Data Store Name
local Store = DataStoreService:GetOrderedDataStore("LeaderBoardData5")

-- [ FUNCTIONS ] --

_G.ForceSet = function(plrName, newTime)
	local num = tonumber(newTime)

	num = num * 1000
	Store:SetAsync(plrName, num)
end

game.ReplicatedStorage.ApplyTime.OnServerEvent:Connect(function(plr, newTime) -- On Event
	
	local num = tonumber(newTime)
	local oldData = Store:GetAsync(plr.UserId)
	
	if oldData then
		oldData = oldData / 1000
	else
		oldData = 1000
	end
	
	---- ANTI CHEAT (needs fixing)
	if num < oldData then
		if num <= 900.00 then
			plr:Kick("No cheating bucko!")
		else
			num = num * 1000
			Store:SetAsync(plr.UserId, num)
		end
	end
	
end)
4 Likes

I’m not even gunna say it again.

I’ve said the solution here, here and here. Bit too many times.

6 Likes

So I put that at the top of the script?

1 Like

Also, no need to get aggressive dude lol. I’m a beginner and I thought the devforum was where I could come for help and feedback. Hell, I’m sure you needed help when you first started out too! This is what I changed it to if you or anybody else wants to help, do you think it’s correct or should I move the BindToClose function to the end?

--[[
	@author TwinPlayzDev_YT
	@since 6/1/2021
	This script will apply the leaderboard time, and check if a player has finished or completed the obby.
	Only saves time when they fully complete course without dieing.
--]]

game:BindToClose(function()
	task.wait(5)
end)
-- [ SERVICES ] --

local DataStoreService = game:GetService("DataStoreService")

-- [ LOCALS ] --

local DataVer = "[DataTimer]" -- Data Store Name
local Store = DataStoreService:GetOrderedDataStore("LeaderBoardData5")

-- [ FUNCTIONS ] --

_G.ForceSet = function(plrName, newTime)
	local num = tonumber(newTime)

	num = num * 1000
	Store:SetAsync(plrName, num)
end

game.ReplicatedStorage.ApplyTime.OnServerEvent:Connect(function(plr, newTime) -- On Event
	
	local num = tonumber(newTime)
	local oldData = Store:GetAsync(plr.UserId)
	
	if oldData then
		oldData = oldData / 1000
	else
		oldData = 1000
	end
	
	---- ANTI CHEAT (needs fixing)
	if num < oldData then
		if num <= 900.00 then
			plr:Kick("No cheating bucko!")
		else
			num = num * 1000
			Store:SetAsync(plr.UserId, num)
		end
	end
	
end)

I’m not being aggressive, or even negative to you in any way.

Also, yes, put that BindToClose function on the top of everything else, except variables.

1 Like

All good, I’ll mess around with the script until it works. Thank you and have a great day! :sunglasses: :+1:t4:

1 Like

The statement you provided can be perceived as somewhat assertive or impatient, but it’s not overtly aggressive. You were obviously expressing frustration or annoyance because you’ve provided the solution multiple times and don’t want to repeat yourself. Whilst you may have done so, this person had no idea, or probably couldn’t find it as he said he’s been stressing about it over a month, you could of had just simply stated you’ve gone through this before and linked it.

2 Likes

Hey Matthew how are you? Also it’s all good man, I don’t want y’all arguing about it. I’m just making posts about this because no matter what I do or what advice anybody gives, it just will not work. Not many people give direct answers on here, it’s always “remoteevent this” and “datastore that” and me being a beginner i’m always lost! Hopefully I find a solution soon though. :sunglasses:

1 Like

I literally said I’m not. Why are you trying to debunk my emotions like that-

1 Like

Hey Diamond how’re you? Also the bindtoclose thing didn’t do anything so ima contact the youtuber lol

It does work…

game:BindToClose(function()
    print("binding")
end)

I’ll check that out today then and here’s another post with all 3 scripts linked so you won’t be confused lol!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.