Leaderstats wont update numbers

So I think I already know the issue, I’m just a little unsure as to how to get around it. Basically everything works but 2 things. I have a gui that keeps track of how many things you harvest (ranging from strawberries to onions etc) Anyways.

Everything is working alright except 2 things.

I have a leaderboard within the player that houses the IntValues of how many items you harvest. And I have a DataStore that’ll save said values. The issue lies either in the harvesting itself or the player HUD.

The script is simple. When the proximity trigger is pressed, It adds +1 to the IntValue (of the correct produce, in this case Cabbage).

But for some reason it isn’t actually adding it. I’m getting no errors- I mean, technically no visible errors. For some reason the “Triggered” part of “script.Parent.Triggered:Connect(…” is underlined yellow and is stating, “Not Found In Class Script”. Which maybe I’m missing something but the script below IS correctly parented under this Proximity Prompt AND it does tell me “Cabbage Added” when the script is complete. So im just torn as to why it isn’t working.

NOTE: Both these scripts are Local Scripts & Separate.

Harvest Script (Found inside the proximity prompt within the model in the game):

local CabbageCount = game.Players.LocalPlayer.ProduceNumberFolder.CabbageCount

script.Parent.Triggered:Connect(function(player)  -- this Triggered underlined yellow
	
	CabbageCount.Value = CabbageCount.Value + 1
	print("Cabbage Added") 
	
end)

and Idk if this is really the issue because regardless the intvalue isn’t rising. Only reason I’m adding it because the script below doesn’t work (correction it works but not as intended); Mainly because the IntValue isn’t updating.
this script merely just takes a look at the produce # and then projects it onto the text icon within the player script:

local CabbageValue = game.Players.LocalPlayer.ProduceNumberFolder.CabbageCount

while wait(.5) do

	script.Parent.Text = CabbageValue.Value
	print("Cabbage Set")   -- This does show up in the Output but it doesn't actually show in game or in editor.
	wait(.5)
	break
end

side note: I do have to run somewhere so if you reply and I don’t respond right away- please don’t be mad! I am grateful for your time to look at my issue :D, this community is a life saver lol.

Not sure what the exact issue is, but I’ve created a server script version of this and it is working fine. Just for the future, try to keep all kinds of values attached to the server rather than letting the client handle it, mainly because it is much easier to exploit those values rather than having them being on the server.

Here’s the code:

local Players = game:GetService("Players")

local Prompt = workspace.TestPart.ProximityPrompt

Prompt.Triggered:Connect(function(player)
	if player.newValue then
		player.newValue.Value = player.newValue.Value + 1
		print(player.newValue.Value)
	end
end)

Players.PlayerAdded:Connect(function(player)
	local newValue = Instance.new("NumberValue", player)
	newValue.Name = "newValue"
end)
1 Like

Yes! I had to change only minor things like the “Prompt” Route but other than that it works perfectly! Thank you so much!

ps. Sorry for my late reply! :smiley: I appreciate your help!!

1 Like