Hello, I made some scripts with a Remote Event and it’s for an admin script
(I tried looking for similar problems like this but I couldn’t understand most of the time so I’m asking for help)
What it’s supposed to do is the player types the cash Amount in a TextBox and the Player’s name in another TextBox. Once that’s done, it sends a signal to a script to give the Player’s Name (TextBox) the amount of cash in the Cash Textbox. The problem is, I tried this but I’ve come to see that I’ve gotten the error ServerScriptService.AdminScripts.ConnectRemotes:8: attempt to concatenate Instance with string
but all that gave me was the print.
I really don’t know much about Remote Events so if you could help then that would help me alot!
Scripts:
Local Script: Button
local cBox = script.Parent.Parent.CashTextBox
local pBox = script.Parent.Parent.PlayerTextBox
local button = script.Parent
local rStorage = game:GetService("ReplicatedStorage")
local folder = rStorage:WaitForChild("adminEvents")
local remoteC = folder:WaitForChild("cashRemote")
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
button.MouseButton1Click:Connect(function()
remoteC:FireServer(plr, tonumber(cBox.Text), pBox.Text)
print("Signal CASH Sent. CASH: "..cBox.Text.." | TO PLAYER: "..pBox.Text)
end)
Server Script: ServerScriptService INSIDE Folder
local rStorage = game:GetService("ReplicatedStorage")
local folder = rStorage:WaitForChild("adminEvents")
local remoteC = folder:WaitForChild("cashRemote")
remoteC.OnServerEvent:Connect(function(sender, cashAmount, playerName)
print("SIGNAL DETECTED: "..sender.Name.." SENT $"..cashAmount.."TO "..playerName)
for _, plr in ipairs(Players:GetPlayers()) do
if plr.Name == playerName then
plr:FindFirstChild("Cash").Value += cashAmount
print("PLAYER FOUND, GIVING $"..cashAmount)
else
warn("USER "..plr.." DOESN'T MATCH "..playerName)
end
end
end)
If I made any mistakes OR I need to improve something in the script then you could tell me and I’d try it.
I am not sure what you mean. From my understanding you are trying to make something for your admin panel which will give another player Cash, correct? When you use :FireServer(), the player who calls the remote is automatically passed. The way you used :FireServer() is making bother the sender and cashAmount arg the player who called the remote. Once you fix the two things I’ve mentioned in my other post it should work.
attempt to perform arithmetic (add) on number and nil means something is wrong with your “Cash” value or your cashAmount value. You can try debugging it by printing things.
Also, I just looked at one of your other replies and think you should fix this.
Instead of remoteC.OnServerEvent:Connect(function(playerName, cashAmount) do remoteC.OnServerEvent:Connect(function(plr, playerName, cashAmount)
If you need help on how to use RemoteEvents, I suggest watching a YouTube video as they can explain everything better than me, lol.