Im also using this blacklistt players system for the touched events someone suggested but still not working
This is of a thing where the player can only claim points after a certain amount of time
Here is my current script:
local DataStoreServce = game:GetService("DataStoreService")
local DebrisService = game:GetService("Debris")
local DataStore = DataStoreServce:GetDataStore("lo1_229112")
local TimeForWait = 5 --//btw this is in scends
function Set(Player)
local s,e = pcall(function()
DataStore:SetAsync(Player.UserId, os.time())
end)
end
game.Players.PlayerRemoving:Connect(function(Player)
local CurrentTime = os.time()
--print(CurrentTime)
Set(Player)
end)
local function TeleportBack(player)
player.Character.HumanoidRootPart.Position = game.Workspace.Lobby.BackToSpawn.Position
end
local blacklist = {};
function foundInList(player)
for _,target in ipairs(blacklist) do
if target == player then
return true;
end
end
return false;
end
local function UnBlackListPlayer(player)
for i,v in ipairs(blacklist) do
if v.Name == player.Name then
table.remove(blacklist, i)
print('cool')
end
end
end
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
for i,v in pairs(blacklist)
do
print(v)
end
if player then
if not foundInList(player) then
table.insert(blacklist,player);
local Data = DataStore:GetAsync(player.UserId)
local Points = player.leaderstats.Points
if Data == nil then
print("Player can get points")
Points.Value = Points.Value + 500
--TeleportBack(player)
Set(player)
--wait(1)
elseif os.time() - Data >= TimeForWait then
print("HWTA")
Points.Value = Points.Value + 500
--TeleportBack(player)
Set(player)
else
print("Player claimed before")
end
--print("Old data is " .. Data .. " new data is .. ".. os.time())
--print("its been ".. os.time() - Data.. " seconds")
end
end
wait(5)
UnBlackListPlayer(player)
end
end)
game:BindToClose(function()
for i,v in pairs(game.Players:GetPlayers()) do
Set(v)
end
end)