Need help with admin panel

Ok I had another error while making this admin panel, can anyone help?
Note: It had no errors but it will still print out the “Player Not available or not working”

script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = game.ReplicatedStorage.Hi

createPartEvent.OnServerEvent:Connect(function(player, name, text, value) 
	if game.Players:FindFirstChild(name) then
		local name2 = game.Players:FindFirstChild(name)
		local Stats = name2.Stats
	
	
	print(name)

	print("recieved")
	wait(.1)
	if text == "Cash" then
		Stats.Cash.Value = value   print("Work")

	elseif text == "Multiplier" then
		Stats.Multiplier.Value = value   print("Work")


	else
		print("not work")
		print(value.."Value")
		print(text.."text")
	end
else
	print("Player Not available or not working")

	end
end)

Every comment here I will heart!

2 Likes

How are you calling the remote event, can we see that script?

1 Like

It’s printing that because it doesn’t find a Instance inside of Players that has the current name you’re giving as argument, it’s either that the “name” argument is simply nil or you’re writing the name wrong.

1 Like
local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = game.ReplicatedStorage.Hi
local buttons = script.Parent.Panel.Buttons.Cash
local Amount = buttons.CashAmount
local Value = buttons.CashType
local name = buttons.name

  buttons.MouseButton1Click:Connect(function()
    createPartEvent:FireServer(name, Value.Text, Amount.Text) -- Added value
end)

I edited the script and it works thanks for helping! I just forgot to add “.Text”, I always get mistaken

TIP - Something I learned you can do is having 1 remote event for many commands instead of multiple remote events, you would just need to send an ActionType. So on client, I send “Kick” and then the server-side checks if ActionType == “Kick”. And you would just have data1, data2,data3 (can be whatever you sent) In my case data2 could be a player name or music id I sent.

1 Like