Hiya, I have an issue where when sending data from the client to the server using a remote event, the server changes the string from a string to ‘nil’ I have tried looking to see where the issue is however I cant find it.
CLient script to send the data to the server
local PlayerName = script.Parent.PlrName.Text -- Gets player name
print("Client Sending Order to Delete for "..PlayerName) -- Prints out name correctly
game.ReplicatedStorage.IFE.DeleteOrder:FireServer(PlayerName) -- Sends data
Script on the server
game.ReplicatedStorage.IFE.DeleteOrder.OnServerEvent:Connect(function(Player, PlayerName)
print("Server Sending Order to Delete for "..tostring(PlayerName))
game.ReplicatedStorage.IFE.DeleteOrder:FireAllClients(tostring(PlayerName))
end)
The recieving client script
game.ReplicatedStorage.IFE.DeleteOrder.OnClientEvent:Connect(function(Player, PlayerName)
print("Client Deleteing for "..tostring(PlayerName))
local button = script.Parent.Orders:FindFirstChild(tostring(PlayerName))
button:Destroy()
end)
The error I get is that the player name is printing as ‘nil’ on the recieving client script
The button does not exist because you have an invalid parameter.
The OnClientEvent does not have a default player parameter. You can just put it as PlayerName.
Also, before destroying the button, I suggest that you’d check if it exists first.
Client Script
game.ReplicatedStorage.IFE.DeleteOrder.OnClientEvent:Connect(function(PlayerName)
local button = script.Parent.Orders:FindFirstChild(tostring(PlayerName))
if button then
print("Client Deleteing for "..tostring(PlayerName))
button:Destroy()
end
end)