Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Reading IntValues in leaderstats returning 0?

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by 2 years ago
Edited 1 year ago

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)

0
I will give it a try but I'm not accessing LocalPlayer though? pianohydra 5 — 2y
0
I have tried it and it is still saying all stats are 0 even from a remote event and local script pianohydra 5 — 2y
Ad

Answer this question