Hey there!
I am currently making a shop system but for some reason the server cant get the players leaderstats. I have tried many solutions such as WaitForChild and FinFirstChild but for both those arguments i got index nil with FindFirstChild/WaitForChild.
The code is in a server script within a button, here is the script:
local serverStore = game:GetService("ServerStorage")
local repStore = game:GetService("ReplicatedStorage")
script.Parent.MouseButton1Click:Connect(function(player) -- Im pretty sure this is returning the player's character but not sure
local leaderstats = player.leaderstats -- Error is ocurring here
if leaderstats.Credits.Value >= 10 then -- Set to 6000
local falClone1 = serverStore.Tools.FAL
local falClone2 = serverStore.Tools.FAL
falClone1.Parent = player.Backpack
falClone2.Parent = player.StartGear
local char = player.Parent -- Same message as below
repStore.Core.Events.Purchased:FireClient(char) -- If this :Connect function variable is returning the players character than this wont work
else
print("Player doesnt have leaderstats, or they havent loaded in properly yet!") -- This wont print
end
end)
This is probably a very simple error but i cant find a way to fix it.
Thanks!