Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Reading IntValues in leaderstats returning 0?

Hi I am new to this platform. I am having an issue with .Touched events. Specifically reading an IntValue. The script is server-side and is in game.Workspace.sell_shop.Sell.Part and the script gets player data from the players leaderstats (Clicks, Money and Rebirths). This is the current code I have so far:

local part = script.Parent
local players = game:GetService("Players")

part.Touched:Connect(function(otherPart)
	if otherPart.Parent:FindFirstChild("Humanoid") then
		local player = players:GetPlayerFromCharacter(otherPart.Parent)
		local clicks = player.leaderstats.Clicks.Value
		print(clicks) -- Prints 0
	end
	
end)

Localscripts can read these leaderstats and scripts in ServerScriptService can get leaderstats

1 answer

Server scripts can't access values in LocalPlayer. You can try firing RemoteEvent and make separate LocalScript in StarterGui or StarterPlayerScripts and when the RemoteEvent is fired, it prints amount of clicks.

Hope this helps!

(Edit: Server can't read values changed by local scripts)

2 comments

0

I will give it a try but I'm not accessing LocalPlayer though?

0

I have tried it and it is still saying all stats are 0 even from a remote event and local script

This discussion is preserved as it was. New answers, comments, and votes are closed.