Datastore broken

Use Instance:WaitForChild() as Clicks may not exist when the script runs.

Thats not good at all. It knows points though which is werid.

The error is not from the data store script

IT kind of is, because my script is LOOKING for the value “Clicks” and somehow cant find it.

This script? (I am working with him on the game)

local plr = game.Players.LocalPlayer
local RS = game:GetService("RunService")
local leaderstats = plr.leaderstats
local parent = script.Parent

local c
c = RS.RenderStepped:Connect(function()
	wait()
	parent.Text = leaderstats.Clicks.Value.." Clicks"
end)

--[[
Future reference:
c:Disconnect()
]]

No, the one in the ClickButton.

Mhm. maybe because there’s a space?

parent.Text = leaderstats.Clicks.Value.." Clicks" <---
local plr = game.Players.LocalPlayer

local RS = game:GetService("RunService")

local leaderstats = plr.leaderstats

local parent = script.Parent

parent.MouseButton1Click:Connect(function()

wait()

leaderstats.Clicks.Value = leaderstats.Clicks.Value + 1

end)

I think the problem is that if this is a local script, then you should fire a remote event instead of doing this

leaderstats.Clicks.Value = leaderstats.Clicks.Value + 1

for example

local event = -- path

event:FireServer()

Then on the server part you could do this

local event = -- path

event.onServerEvent:Connect(function(plr)
      local leaderboard = game.Players[plr.Name]:WaitForChild("leaderstats")
      local yourValue = -- path here
      
      yourValue = yourValue + 150
end)

This is a localscript, but eer since I put in your DS and deleted mine, it stopped working.

Maybe his uses something different?

the problem is the client changes the value. If the server tries to save that, it will only see the default value (in this case its 0) so it won’t ever update.

That’s why you should use remote events

local event = Clicks-- path

	event.onClicked:Connect(function(plr)
	local leaderboard = game.Players[plr.Name]:WaitForChild("leaderstats")
	local Clicks = Clicks -- path here

		Clicks = Clicks + 1
end)

?

image
So what is the correct option?

Instead of making two datastores, make one that will save both values in 1 table, refer to these two videos, they will help you with your problem.

How to make and use DataStore:

How to store more than one value in your DataStore:

1 Like

This is unrealted but on the second video the fact that he ended with gang gang just tells you he knows what he is doing.
:rofl:

2 Likes

BAck to the events- can you fix the one I incorrectly did?


Still did not work with the video.

Ok so… did you try using the script without modifying it? So i can see if it works for you

That bug is pretty self explanatory, clicks is not a valid member of that folder, meaning that it either is not in that folder YET, or it never existed in that folder. If the former is what you think the issue might be, just add a :WaitForChild("Clicks") and that should fix it.