On touch make leaderstat go up by +1

Yes and now I have the new script made by @darkvrn

Not sure how to fix the Data Queue, usually happens when any kind of data is added, its especially odd since its only one thing being updated, i only issue is that pcall prevents errors, not warnings, plus it odd that 1 point is added to a queue while i have a level script that can handle a lot more.

@MakerDoe Not the entire code, only the Pumpkins IntValue

@westyboy609 I have fixed the Data Queue:

ocal DataStoreService = game:GetService("DataStoreService"):GetDataStore("myDataStore")

debounce = false

pumpkins = game.Workspace.Pumpkins

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local timeingame = Instance.new("IntValue", leaderstats)
	timeingame.Name = "Pumpkins"
	timeingame.Value = DataStoreService:GetAsync(player.UserId, timeingame.Value)

	timeingame:GetPropertyChangedSignal("Value"):Connect(function()
		
			pcall(function()
				DataStoreService:UpdateAsync(player.UserId, timeingame.Value)
			end)

	end)
	game.Players.PlayerRemoving:Connect(function()
pcall(function()
		DataStoreService:SetAsync(player.UserId, timeingame.Value)
	end)
	end)

	for _,Pumpkin in pairs(pumpkins:GetChildren()) do
		if Pumpkin:IsA("Part") then
			Pumpkin.Touched:Connect(function()
				if not debounce then
					debounce = true
					timeingame.Value += 1
					wait(1)
					debounce = false
				end
			end)
		end
	end
end)

I dont think the pcall’s are nessecary but it works either way.

1 Like

Yeah, but it says here “Time,” not Pumpkin. It’s inside the KillOnTouch function.

looking at the script, the Variable of the pumpkins value is timeingame, but he is using it as points

Yeah like what I have said he is updating “Time” not Pumpkin inside the KillOnTouch funciton.

1 Like

Doesnt change my point, he is using it as points, not time

1 Like

This is due to the fact that I copy and pasted a time script and forgot to edit some values, my mistake.

1 Like

Now, sometimes it never updates on touch, and it says at its original value, and some players still have the -