This code is supposed to get the name of an item (on the client), then pass it to the server so it can update the value of a string (server side). The client and the server give different outputs for the same variable.
Client
script.Parent.Hitbox.MouseButton1Click:Connect(function(player)
if script.Parent.ItemName then
local Plant = string.gsub(script.Parent.ItemName.Value, "Seeds", "")
print(Plant)--prints Carrot (Carrot is the plant used for testing)
game.ReplicatedStorage.Farming.UpdateSelection:FireServer(player,Plant)
end
end)
Yes. The first parameter in the connection function of OnServerEvent is always the player instance who fired the remote event. In other words, the first argument you put in the function on the client will always be the second parameter of the connected function on the server.