ServerScriptService.Script:3: attempt to index number with 'leaderstats'

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Fixing a bug!

  2. What is the issue? ServerScriptService.Script:3: attempt to index number with ‘leaderstats’

  3. What solutions have you tried so far? Tried fixing it and looking at dev forum yet found nothing.

local function getmoonies(moonies, lvl, xp, Player)
	repeat wait() until Player
	Player.leaderstats.Moonies.Value = Player.leaderstats.Moonies.Value + Player.leaderstats.LevelMrBest.Value
	Player.leaderstats.XPMrBest.Value = Player.leaderstats.XPMrBest.Value + 1
	
	print("gave money")
end

game:GetService("ReplicatedStorage").moneyGet.OnServerEvent:Connect(getmoonies)
local function button1click()
	if right1.Value == true then
		remoteEvent:FireServer(moonies.Value, level.Value, xp.Value, Player)
		reloadbuttons()
	elseif right1.Value == false then
		reloadbuttons()
		print("wrong")
		remoteEvent1:FireServer(moonies.Value, Player, level.Value, moneytake.Value)
	end
end
local function getmoonies(moonies, lvl, xp, Player)
	repeat wait() until Player
if Player:FindFirstChild("leaderstats") then
	Player.leaderstats.Moonies.Value = Player.leaderstats.Moonies.Value + Player.leaderstats.LevelMrBest.Value
	Player.leaderstats.XPMrBest.Value = Player.leaderstats.XPMrBest.Value + 1
	
	print("gave money")
end
end

it gives me this error: ServerScriptService.Script:3: attempt to index number with ‘FindFirstChild’

The Player parentheses return number value not the player.

since the error sayd index “number”

doesnt that mean its giving me my userid?

try to print the Player parameter

try print player, check if player nil or not

it doesnt even print anything…

that mean your script have problem

that means its working only sometimes so yeah idk whats wrong tho

try add wait on line 1 like wait(2)

somehow its working right now but it didnt work the first time which i find strange

ok could try to print the moonies variable value in the client script?

it didnt print anything cause i didnt launch the goofy ahh remoteevent

try thiss code

local function getmoonies(Player, moonies, lvl, xp)
	repeat wait() until Player
	Player.leaderstats.Moonies.Value = Player.leaderstats.Moonies.Value + Player.leaderstats.LevelMrBest.Value
	Player.leaderstats.XPMrBest.Value = Player.leaderstats.XPMrBest.Value + 1
	
	print("gave money")
end

game:GetService("ReplicatedStorage").moneyGet.OnServerEvent:Connect(getmoonies)

he try print already. breh did u even read the chat?

it prints -23 what in the actual cadoosay

hold on thats the xp value…???

wait ill try to change the things up a bit

have you tried my codes above?

the problem your having is because your putting the variable parameter at wrong position, the first parameter of OnServerEvent is always gonna be player that fired it